%s', esc_html__('Alertify', 'alertify')), 'manage_woocommerce', 'alertify-settings', array($this, 'display_settings_page'), 99999 ); } public function register_settings() { register_setting('alertify_options', 'alertify_options', array($this, 'sanitize_settings')); // General Settings add_settings_section( 'alertify_general_settings', '', null, 'alertify_general_options' ); add_settings_field( 'enable_notifications', esc_html__('Enable Notifications', 'alertify'), array($this, 'render_enable_field'), 'alertify_general_options', 'alertify_general_settings' ); // Frontend Text Settings add_settings_section( 'alertify_frontend_text', esc_html__('Frontend Text', 'alertify'), null, 'alertify_general_options' ); add_settings_field( 'button_text', esc_html__('Button Label', 'alertify'), array($this, 'render_text_field'), 'alertify_general_options', 'alertify_frontend_text', array('key' => 'button_text', 'default' => esc_html__('Notify When Available', 'alertify')) ); add_settings_field( 'popup_title', esc_html__('Popup Title', 'alertify'), array($this, 'render_text_field'), 'alertify_general_options', 'alertify_frontend_text', array('key' => 'popup_title', 'default' => esc_html__('Get Back In Stock Notification', 'alertify')) ); add_settings_field( 'submit_button_text', esc_html__('Submit Button Text', 'alertify'), array($this, 'render_text_field'), 'alertify_general_options', 'alertify_frontend_text', array('key' => 'submit_button_text', 'default' => esc_html__('Notify Me', 'alertify')) ); // Email Settings add_settings_section( 'alertify_email_settings', '', null, 'alertify_email_options' ); add_settings_field( 'emails_per_hour', esc_html__('Emails Per Hour', 'alertify'), array($this, 'render_emails_per_hour_field'), 'alertify_email_options', 'alertify_email_settings' ); add_settings_field( 'email_template', esc_html__('Email Template', 'alertify'), array($this, 'render_email_template_field'), 'alertify_email_options', 'alertify_email_settings' ); } public function sanitize_settings($input) { $sanitized = array(); $sanitized['enable_notifications'] = isset($input['enable_notifications']) ? 1 : 0; $sanitized['emails_per_hour'] = absint($input['emails_per_hour']); $sanitized['email_template'] = wp_kses_post($input['email_template']); // New text fields $text_fields = array('button_text', 'popup_title', 'submit_button_text'); foreach ($text_fields as $field) { $sanitized[$field] = isset($input[$field]) ? sanitize_text_field($input[$field]) : ''; } return $sanitized; } public function render_enable_field() { $options = get_option('alertify_options', array()); $enabled = isset($options['enable_notifications']) ? $options['enable_notifications'] : 1; ?>


get_default_template(); $value = isset($options['email_template']) ? $options['email_template'] : $default_template; ?>


{customer_name} -
{product_name} -
{product_link} -
{site_name} -
{product_price} -
{product_sku} -
{product_image} -
{unsubscribe_link} -

403, 'back_link' => true, )); } // Process test email form here } $active_tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : 'general'; ?>

display_subscriptions_list(); ?>

query( $wpdb->prepare( sprintf( "DELETE FROM {$wpdb->prefix}alertify_subscriptions WHERE id IN (%s)", implode(',', array_fill(0, count($ids), '%d')) ), $ids ) ); // Delete cache after modification wp_cache_delete('alertify_all_subscriptions', 'alertify'); } } // Try to get from cache first $subscriptions = wp_cache_get('alertify_all_subscriptions', 'alertify'); if (false === $subscriptions) { // Cache miss - get from database // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery $subscriptions = $wpdb->get_results( "SELECT s.*, p.post_title as product_name FROM {$wpdb->prefix}alertify_subscriptions s LEFT JOIN {$wpdb->posts} p ON s.product_id = p.ID ORDER BY s.created_at DESC" ); // Cache the results for 5 minutes wp_cache_set('alertify_all_subscriptions', $subscriptions, 'alertify', 5 * MINUTE_IN_SECONDS); } ?>
product_name); ?> name); ?> email); ?> phone); ?> status)); ?> created_at))); ?>
test_email($test_email); if ($sent) { add_settings_error('alertify_test_email', 'test_email_sent', esc_html__('Test email sent successfully.', 'alertify')); } else { add_settings_error('alertify_test_email', 'test_email_failed', esc_html__('Failed to send test email. Please check your email settings.', 'alertify')); } } } } new ALERTIFY_Admin();