admin_url( 'admin-ajax.php' ), 'i18n' => array( 'saving' => __( 'Creating…', 'loyaltyspin' ), 'created' => __( 'Created. Set the cart amount and click Save changes.', 'loyaltyspin' ), 'error' => __( 'Something went wrong. Please try again.', 'loyaltyspin' ), 'pick' => __( 'Choose gift image', 'loyaltyspin' ), 'use' => __( 'Use this image', 'loyaltyspin' ), 'running' => __( 'Simulating…', 'loyaltyspin' ), ), ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : ''; if ( false !== strpos( (string) $hook, 'loyaltypress-settings' ) && in_array( $tab, array( 'spin', 'coins' ), true ) ) { wp_enqueue_media(); } if ( false !== strpos( (string) $hook, 'loyaltypress-settings' ) && 'gifts' === $tab ) { wp_enqueue_script( 'wc-enhanced-select' ); wp_enqueue_style( 'woocommerce_admin_styles' ); wp_enqueue_media(); } if ( false !== strpos( (string) $hook, 'loyaltypress-spin' ) ) { \LoyaltyPress\Frontend\My_Account::register_assets(); wp_enqueue_script( 'loyaltypress-front' ); wp_enqueue_style( 'loyaltypress-front' ); wp_enqueue_media(); } } /** * Flash notices (set via redirect ?loyaltypress_msg=). */ public static function notices() { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- display only. if ( empty( $_GET['page'] ) || 0 !== strpos( sanitize_key( wp_unslash( $_GET['page'] ) ), 'loyaltypress' ) || empty( $_GET['loyaltypress_msg'] ) ) { return; } $msg = sanitize_text_field( rawurldecode( sanitize_text_field( wp_unslash( $_GET['loyaltypress_msg'] ) ) ) ); $type = ! empty( $_GET['loyaltypress_err'] ) ? 'error' : 'success'; // phpcs:enable echo '

' . esc_html( $msg ) . '

'; } /** * Settings (and, in the free edition, Get Pro) links on the Plugins screen. * * @param array $links Links. * @return array */ public static function action_links( $links ) { $extra = array( '' . esc_html__( 'Settings', 'loyaltyspin' ) . '' ); if ( ! Settings::has_pro_code() ) { $extra[] = '' . esc_html__( 'Get Pro', 'loyaltyspin' ) . ''; } return array_merge( $extra, $links ); } /** * Free edition: what Pro adds, with a link to buy it. Shown only on LoyaltySpin's own dashboard. */ private static function pro_card() { if ( Settings::has_pro_code() ) { return; } ?>

rawurlencode( $msg ) ); if ( $error ) { $args['loyaltypress_err'] = 1; } wp_safe_redirect( add_query_arg( $args, $url ) ); exit; } /** * Capability gate for every admin-post handler (each handler then verifies its nonce). */ public static function require_cap() { if ( ! current_user_can( self::CAP ) ) { wp_die( esc_html__( 'You do not have permission to do this.', 'loyaltyspin' ), 403 ); } } /** * Dashboard. */ public static function dashboard() { global $wpdb; $totals = Ledger::totals(); $p = $wpdb->prefix . 'loyaltypress_'; // phpcs:disable WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared $spins_used = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i', $p . 'spin_results' ) ); $spins_open = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %i WHERE status = 'available'", $p . 'spin_tokens' ) ); $draws_open = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %i WHERE status IN ('open','ready')", $p . 'draws' ) ); $draws_ready = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %i WHERE status = 'ready'", $p . 'draws' ) ); $top = $wpdb->get_results( $wpdb->prepare( 'SELECT t.user_id, t.balance_after FROM %i t INNER JOIN (SELECT MAX(id) mid FROM %i GROUP BY user_id) m ON m.mid = t.id ORDER BY t.balance_after DESC LIMIT 10', $p . 'coin_ledger', $p . 'coin_ledger' ) ); $recent = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i ORDER BY id DESC LIMIT 12', $p . 'coin_ledger' ) ); $prize_mix = $wpdb->get_results( $wpdb->prepare( 'SELECT prize_label, COUNT(*) c FROM %i GROUP BY prize_label ORDER BY c DESC LIMIT 8', $p . 'spin_results' ) ); // phpcs:enable $liability = \LoyaltyPress\Coins\Redeem::value_of( max( 0, $totals['outstanding'] ) ); ?>

user_id ); ?>
display_name : '#' . $row->user_id ); ?>balance_after ) ); ?>

user_id ); ?>
display_name : '#' . $row->user_id ); ?>reason ); ?>amount > 0 ? '+' : '' ) . $row->amount ); ?>

prize_label ); ?>c ) ); ?>
0 ? round( $st['members'] / $st['customers'] * 100 ) : 0; ?>

·

prefix . 'loyaltypress_audit_log'; $led = $wpdb->prefix . 'loyaltypress_coin_ledger'; // phpcs:disable WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared $saved_tabs = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT object FROM %i WHERE action = 'settings_saved'", $audit ) ); $prizes_saved = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT id FROM %i WHERE action = 'prizes_saved' LIMIT 1", $audit ) ); $test_order = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT id FROM %i WHERE type = 'earn' AND order_id > 0 LIMIT 1", $led ) ); // phpcs:enable $jobs = function_exists( 'as_next_scheduled_action' ) && as_next_scheduled_action( 'loyaltypress_hourly', array(), 'loyaltypress' ); $steps = array(); if ( Settings::module_on( 'coins' ) ) { $steps[] = array( in_array( 'tab:coins', $saved_tabs, true ), __( 'Name your coins and set the earn & redeem rates', 'loyaltyspin' ), __( 'Pick a name customers will love and decide how much cashback you give.', 'loyaltyspin' ), admin_url( 'admin.php?page=loyaltypress-settings&tab=coins' ) ); } if ( Settings::module_on( 'tiers' ) ) { $steps[] = array( in_array( 'tab:tiers', $saved_tabs, true ), __( 'Set your membership tiers', 'loyaltyspin' ), __( 'Choose the spend levels and the % off each level gets.', 'loyaltyspin' ), admin_url( 'admin.php?page=loyaltypress-settings&tab=tiers' ) ); } if ( Settings::module_on( 'gifts' ) ) { $steps[] = array( ! empty( $raw['gifts']['rules'] ), __( 'Add a gift rule (optional)', 'loyaltyspin' ), __( 'Give a free product when the cart reaches an amount.', 'loyaltyspin' ), admin_url( 'admin.php?page=loyaltypress-settings&tab=gifts' ) ); } if ( Settings::module_on( 'spin' ) ) { $steps[] = array( $prizes_saved, __( 'Review the wheel prizes and test the odds', 'loyaltyspin' ), __( 'Edit the 6 sample prizes and press "Test the odds".', 'loyaltyspin' ), admin_url( 'admin.php?page=loyaltypress-spin' ) ); } $steps[] = array( (bool) $jobs, __( 'Background jobs are scheduled', 'loyaltyspin' ), __( 'Needed for coin expiry, reminders, birthdays and draw checks. For exact timing, add a server cron for wp-cron.php.', 'loyaltyspin' ), admin_url( 'admin.php?page=loyaltypress-tools' ) ); $steps[] = array( $test_order, __( 'Place a test order', 'loyaltyspin' ), __( 'Order as a customer (Cash on Delivery is fine), mark it Processing and check the My Rewards page.', 'loyaltyspin' ), wc_get_page_permalink( 'shop' ) ); $done = count( array_filter( wp_list_pluck( $steps, 0 ) ) ); if ( count( $steps ) === $done ) { return; } ?>

    $st ) : ?>
' . esc_html( $label ) . '' . esc_html( $value ) . '' . ( $sub ? '' . esc_html( $sub ) . '' : '' ) . ''; } }