:not(.mtn_content) > span::after { content: "' . esc_html( $mtn_title ) . '"; text-decoration: underline dotted; } .mtn_content::before { content: "' . esc_html( $mtn_content ) . '"; }'; } } /** * Create or update the necessary database tables for the plugin. * * @global wpdb $wpdb WordPress database abstraction object. * @return bool True on success, false on failure. */ public static function affiai_bdd() { global $wpdb; // Table names $table_name = $wpdb->prefix . 'afx_cache'; $table_name2 = $wpdb->prefix . 'afx_amz_temp'; // Character set and collation $charset_collate = $wpdb->get_charset_collate(); // Include upgrade.php for dbDelta() require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // SQL queries for creating tables $sqls[2] = "CREATE TABLE $table_name ( id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, name varchar(32) NOT NULL, value mediumtext NOT NULL, post_id int(11) UNSIGNED NOT NULL, auto tinyint(1) DEFAULT 0, old tinyint(1), off tinyint(1), afx tinyint(1), date varchar(30), PRIMARY KEY (id), UNIQUE KEY name (name), KEY post_id (post_id) ) $charset_collate;"; $sqls[3] = "CREATE TABLE $table_name2 ( id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, asin varchar(13) NOT NULL, country varchar(8) NOT NULL, title varchar(191), url varchar(191), description varchar(191), image_url varchar(191), price varchar(30), old_price varchar(30), discount varchar(30), currency varchar(5), rating varchar(5), nb_reviews varchar(10), search varchar(191), category varchar(191), gtin varchar(15), params text, offer_state varchar(16) DEFAULT NULL, source_fetched_at bigint(20) unsigned DEFAULT NULL, source_context char(64) DEFAULT NULL, sim varchar(15), date varchar(30), PRIMARY KEY (id), UNIQUE KEY asin (asin, country) ) $charset_collate;"; // Execute SQL queries using dbDelta() foreach ( $sqls as $sql ) { dbDelta( $sql ); } // Check if there were any errors $success = empty( $wpdb->last_error ); foreach ( array( 'offer_state', 'source_fetched_at', 'source_context' ) as $field ) { $success = $success && (bool) $wpdb->get_row( $wpdb->prepare( "SHOW COLUMNS FROM $table_name2 LIKE %s", $field ) ); } return $success; } /** * Encrypts a URL using AES-128-ECB encryption and returns the encrypted URL with a prefix. * * @param string $url The URL to encrypt. * @return string The encrypted URL with a prefix. */ public static function affiai_crypt_url( $url ) { $filename = AFFIAI_PLUGIN_DIR . 'admin' . DIRECTORY_SEPARATOR . 'affiai_st.json'; // If the file does not exist, return the original URL. if ( ! file_exists( $filename ) ) { return $url; } // Get the encryption key from the file. $st = file_get_contents( $filename ); $st = json_decode( $st, true ); // Encrypt the URL using the encryption key. $urlc = openssl_encrypt( $url, 'AES-128-ECB', $st['st'] ); // Replace the characters +, / and = with -, _ and , respectively. $urlc = strtr( $urlc, '+/=', '-_,' ); // Return the encrypted URL with a prefix. return AFFIAI_PLUGIN_URL . 'image/prod/' . $urlc; } /** * Update the plugin database if necessary. * * This function updates the plugin database if the version of the plugin has changed or if the version is not set yet. * It also updates the license system and the count of updates. * If the version is less than or equal to 2.5.0, it clears the cache. * * @return void */ public static function affiai_upd_bdd() { $a_version = get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_version' ); $plugin_data = get_plugin_data( AFFIAI_PLUGIN_FIL, false ); $plugin_version = $plugin_data['Version']; $cache_schema_key = AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_cache_v2'; if ( $a_version === $plugin_version && ! get_option( $cache_schema_key ) ) { if ( self::affiai_bdd() ) { update_option( $cache_schema_key, 1 ); } return; } if ( empty( $a_version ) || ( $a_version != $plugin_version ) ) { self::delete_transients( AFFIAI_PLUGIN_NAME . '_march' ); if ( ! self::affiai_bdd() ) { return; } update_option( $cache_schema_key, 1 ); self::delete_transients( AFFIAI_PLUGIN_NAME . '_' ); self::delete_transients( 'aauto_' . AFFIAI_PLUGIN_NAME . '_' ); update_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_version', $plugin_version ); } } /** * Deletes cache with ID 0. * * @return void */ public static function affiai_upd_wgt() { self::delete_cache( '0' ); } /** * Register settings for the plugin. * * @return void */ public static function register_setting() { // Array of supported merchants self::$merchants = array( 'amazon' => 'Amazon', ); // Array of supported templates self::$templates = array( 'grid' => __( 'Grid (multi-column)', 'affiliate-ai-lite' ), ); // Array of supported cache time self::$time_cache = array( __( 'Every day', 'affiliate-ai-lite' ) => 86400, __( 'Every 2 days', 'affiliate-ai-lite' ) => 172800, __( 'Every 3 days', 'affiliate-ai-lite' ) => 259200, __( 'Every week', 'affiliate-ai-lite' ) => 604800, __( 'Every month', 'affiliate-ai-lite' ) => 2592000, __( 'Every 3 months', 'affiliate-ai-lite' ) => 7776000, ); // Array of user rights self::$user_right = array( __( 'Administrator', 'affiliate-ai-lite' ) => 'manage_options', __( 'Editor', 'affiliate-ai-lite' ) => 'edit_posts', __( 'Subscriber', 'affiliate-ai-lite' ) => 'read', ); // Array of all registered options $settings = array( 'template_sst' => array( 'type' => 'string', 'default' => 'small', ), 'cta_type' => array( 'type' => 'string', 'default' => 'all', ), 'rating_type' => array( 'type' => 'string', 'default' => 'scircle', ), 'pros_title' => array( 'type' => 'string', 'default' => __( 'PROS', 'affiliate-ai-lite' ), ), 'cons_title' => array( 'type' => 'string', 'default' => __( 'CONS', 'affiliate-ai-lite' ), ), 'structured_data' => array( 'type' => 'boolean', 'default' => false, ), 'auto_descr' => array( 'type' => 'boolean', 'default' => false, ), 'hide_link' => array( 'type' => 'boolean', 'default' => false, ), 'show_clock' => array( 'type' => 'boolean', 'default' => false, ), 'user_right' => array( 'type' => 'string', 'default' => 'manage_options', ), 'nb_lines' => array( 'type' => 'integer', 'default' => 4, ), 'time_cache' => array( 'type' => 'integer', 'default' => 86400, ), 'hide_price' => array( 'type' => 'boolean', 'default' => false, ), 'geoip' => array( 'type' => 'boolean', 'default' => false, ), 'debug' => array( 'type' => 'boolean', 'default' => false, ), 'mentions' => array( 'type' => 'array', 'default' => array( '0' => false, '1' => '', '2' => '', ), ), 'wpautop' => array( 'type' => 'boolean', 'default' => false, ), 'amazon_tag' => array( 'type' => 'string', 'default' => '', ), 'amazon_creators_key' => array( 'type' => 'string', 'default' => '', ), 'amazon_creators_secret' => array( 'type' => 'string', 'default' => '', ), 'amazon_api_version' => array( 'type' => 'string', 'default' => 'v3', ), 'timer_amz' => array( 'type' => 'boolean', 'default' => false, ), 'amazon_api_key' => array( 'type' => 'string', 'default' => '', ), 'amazon_api_secret' => array( 'type' => 'string', 'default' => '', ), 'amazon_country' => array( 'type' => 'string', 'default' => 'com', ), 'amazon_tag_guest' => array( 'type' => 'string', 'default' => '', ), 'conv_sst' => array( 'type' => 'boolean', 'default' => false, ), 'sst_choice' => array( 'type' => 'array', 'default' => array( 'homepage' => 0, 'categories' => 0 ), ), ); foreach ( $settings as $key => $setting ) { register_setting( AFFIAI_PLUGIN_NAME . '-shopping', AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_' . $key, $setting ); } } /** * Retrieves data from the 'afx_cache' table in the WordPress database based on the cache ID (custom transients). * * @global wpdb $wpdb WordPress database abstraction object. * @param string $cacheid The cache ID to retrieve data for. * @return mixed|false The unserialized data from the cache table if found, false otherwise. */ private static function get_cache_afx( $cacheid ) { global $wpdb; if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $table_name = $wpdb->prefix . 'afx_cache'; $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $sql = $wpdb->prepare( "SELECT value FROM $table_name WHERE name = %s LIMIT 1", $cacheid ); $transient = $wpdb->get_results( $sql ); $wpdb->suppress_errors( $flag ); if ( empty( $transient ) ) { return false; } return maybe_unserialize( $transient[0]->value ); } return false; } /** * Adds a cache to the database table 'afx_cache' or updates an existing one if the cache already exists. * * @param array $cache An associative array containing the cache data to be added or updated. * The array must contain the following keys: * - 'name': The name of the cache. * - 'value': The value of the cache. * - 'post_id': The ID of the post associated with the cache. * - 'auto': Whether the cache was generated automatically or not. * - 'old': If an older product is stored in memory (optional). * - 'off': If a product no longer exists (optional). * - 'afx': If quota is consumed (optional). * - 'date': The date the cache was created or updated (optional). * * @return bool True if the cache was added or updated successfully, false otherwise. */ private static function add_cache_afx( $cache ) { global $wpdb; if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $table_name = $wpdb->prefix . 'afx_cache'; $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $sql = $wpdb->prepare( "INSERT INTO $table_name (name,value,post_id,old,off,afx,date) VALUES (%s,%s,%d,%d,%d,%d,%s) ON DUPLICATE KEY UPDATE value = VALUES(value), post_id = VALUES(post_id), auto = VALUES(auto), old = VALUES(old), off = VALUES(off), afx = VALUES(afx), date = VALUES(date)", $cache['name'], $cache['value'], $cache['post_id'], ! empty( $cache['old'] ) ? $cache['old'] : 0, ! empty( $cache['off'] ) ? $cache['off'] : 0, ! empty( $cache['afx'] ) ? $cache['afx'] : 0, ! empty( $cache['date'] ) ? $cache['date'] : round( current_time( 'timestamp' ) ) ); $wpdb->query( $sql ); $wpdb->suppress_errors( $flag ); return true; } return false; } // Insert temp amazon into affi table for saving private static function add_temp_amz_afx( $save ) { global $wpdb; if ( empty( $wpdb ) || ! ( $wpdb instanceof wpdb ) ) { return false; } $table_name = $wpdb->prefix . 'afx_amz_temp'; $wpdb->query('START TRANSACTION'); foreach ( $save as $k => $s ) { // Check or clean if necessary $date_value = ! empty( $s['date'] ) ? $s['date'] : round( current_time( 'timestamp' ) ); $sql = $wpdb->prepare( "INSERT INTO $table_name (asin, country, title, url, description, image_url, price, old_price, discount, currency, rating, nb_reviews, category, gtin, params, sim, date, offer_state, source_fetched_at, source_context) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s) ON DUPLICATE KEY UPDATE title = VALUES(title), url = VALUES(url), description= VALUES(description), image_url = VALUES(image_url), price = VALUES(price), old_price = VALUES(old_price), discount = VALUES(discount), currency = VALUES(currency), rating = VALUES(rating), nb_reviews = VALUES(nb_reviews), category = VALUES(category), gtin = VALUES(gtin), params = VALUES(params), sim = VALUES(sim), date = VALUES(date), offer_state = VALUES(offer_state), source_fetched_at = VALUES(source_fetched_at), source_context = VALUES(source_context)", $k, $s['country'], $s['title'], $s['url'], !empty( $s['description'] ) && is_array($s['description']) ? wp_json_encode($s['description']) : ( !empty( $s['description'] ) ? $s['description'] : null ), $s['image'], $s['price'], $s['discount_price'], $s['discount'], $s['currency'], null, null, ( $s['category'] ?? null ), $s['gtin'], $s['params'], ( $s['sim'] ?? null ), $date_value, $s['offer_state'] ?? null, $s['source_fetched_at'] ?? 0, self::integrity_context() ); if ( false === $wpdb->query( $sql ) ) { $wpdb->query('ROLLBACK'); return false; } } $wpdb->query('COMMIT'); return true; } /** * Retrieves temporary Amazon Affiliate data based on specified parameters. * * @param string $keyword The keyword to search for. * @param array $ids The array of ASINs to filter the results by. * @param string $param The parameter to filter the results by. * @param string $cauto The category to filter the results by. * @param string $country The country to filter the results by. * @return mixed Returns the retrieved data if successful, false otherwise. */ private static function get_temp_amz_afx( $keyword, $ids, $param, $cauto, $country ) { global $wpdb; if ( empty( $wpdb ) || ! ( $wpdb instanceof wpdb ) ) { return false; } $table_name = $wpdb->prefix . 'afx_amz_temp'; $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $sql = $wpdb->prepare( "SELECT * FROM $table_name WHERE country = %s AND source_context = %s AND offer_state = %s", $country, self::integrity_context(), 'present' ); if ( ! empty( $keyword ) ) { $sql .= $wpdb->prepare( " AND search LIKE %s", '%' . $wpdb->esc_like( $keyword ) . '%' ); } elseif ( ! empty( $ids['asin'] ) ) { $asins = array_values( array_unique( array_filter( array_map( static function( $asin ) { return strtoupper( trim( $asin ) ); }, explode( ',', $ids['asin'] ) ), 'strlen' ) ) ); if ( ! $asins ) { $wpdb->suppress_errors( $flag ); return false; } // Escape and format each value of asin $formatted_asins = array_map(function ($asin) use ($wpdb) { return $wpdb->prepare('%s', $asin); }, $asins); // Build the IN clause with the formatted values $in_clause = '(' . implode(',', $formatted_asins) . ')'; $sql .= " AND asin IN $in_clause"; } if ( ! empty( $keyword ) && ! empty( $param ) ) { $sql .= $wpdb->prepare( " AND params LIKE %s", '%' . $wpdb->esc_like( $param ) . '%' ); } if ( ! empty( $keyword ) && ! empty( $cauto ) ) { $sql .= $wpdb->prepare( " AND category LIKE %s", '%' . $wpdb->esc_like( $cauto ) . '%' ); } //where date is not > 2 hrs $sql .= " AND date > " . ( round( current_time( 'timestamp' ) ) - 7200 ); if ( empty( $ids['asin'] ) ) { //order by id $sql .= " ORDER BY id ASC"; } else { //order by asin $sql .= " ORDER BY FIELD(asin, " . implode(',', $formatted_asins) . ")"; } $transient = $wpdb->get_results( $sql ); $wpdb->suppress_errors( $flag ); if ( empty( $transient ) ) { return false;} // Explicit multi-item requests may reuse this cache only when every // requested ASIN is present. A partial hit must reach the normal API path. if ( isset( $asins ) ) { $cached_asins = array_map( static function( $row ) { return strtoupper( trim( (string) $row->asin ) ); }, $transient ); if ( array_diff( $asins, $cached_asins ) ) { return false; } } return $transient; } /** * Check if a string is similar to any string in an array. * * @param string $sNeedle The string to search for. * @param array $aHaystack The array of strings to search in. * @return bool True if the string is similar to any string in the array, false otherwise. */ public static function similar_in_array( $sNeedle, $aHaystack ) { foreach ( $aHaystack as $sKey ) { if ( stripos( strtolower( $sKey ), strtolower( $sNeedle ) ) !== false ) { return true; } } return false; } /** * Clean GTIN array by removing invalid values and padding valid ones to 13 digits. * * @param array $array Array of GTIN values. * @param string $merch Merchant name to exclude from the cleaning process. * @return array Array of cleaned and padded GTIN values. */ public static function clean_gtin( $array, $merch ) { $resp = array(); foreach ( $array as $k => $v ) { $v = explode( '_', $v ); if ( empty( $v[1] ) ) { continue; } if ( $v[0] != $merch && ! empty( $v[1] ) ) { if ( ! preg_match( '/^[0-9]+$/', $v[1] ) ) { continue; } if ( strlen( $v[1] ) < 12 && strlen( $v[1] ) > 13 ) { continue; } $gtin = str_pad( $v[1], 13, '0', STR_PAD_LEFT ); $resp[] = $gtin; } } return $resp; } /** * Test Amazon function. * This function is used to test the Amazon API and display the response. * * @return void */ public static function affiai_test_amzn() { if ( ! current_user_can( 'manage_options' ) || ! check_ajax_referer( 'afx-admin-ajax-nonce', 'nonce', false ) ) { wp_send_json_error( 'Forbidden', 403 ); } $response = self::products_amazon( 'test', array(), array( 'test_code' => 1, 'auto' => 0 ), array() ); $output = '
' . esc_html__( 'For some countries (like the US), we recommend using "Button only."', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-options', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_cta_type' ) ); // Check if "Call to action type" is not "Button only" to determine whether to hide the option "Merchant name in button" (with JS) if ( get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_cta_type' ) != 'btn' ) { $_hide_btn = ' affiai_mcht_btn_hide'; } else { $_hide_btn = ''; } // Add settings field for "Merchant name on button" add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mcht_btn', __( 'Merchant name on button', 'affiliate-ai-lite' ), function() { echo ' ' . esc_html__( 'Enable this option if you want to show the merchant name on the CTA button. (ex. Buy on Amazon)', 'affiliate-ai-lite' ) . ''; echo ''; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-options', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mcht_btn', 'class' => 'affiai_mcht_btn' . $_hide_btn, ) ); // Add settings field for "Rating type" add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_rating_type', __( 'Rating type', 'affiliate-ai-lite' ), function() { $option = get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_rating_type' ); echo ''; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-options', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_rating_type' ) ); // Add settings field for "Pros & cons labels" add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_pros_cons_title', __( 'Pros & cons labels', 'affiliate-ai-lite' ), function() { echo ''; echo ''; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-options', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_pros_cons_title' ) ); /** * Adds a settings section for advanced settings */ add_settings_section( AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', __( 'Advanced settings', 'affiliate-ai-lite' ), null, 'afx-options' ); // Adds a settings field for caching time add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_time_cache', __( 'Caching time', 'affiliate-ai-lite' ), function() { $option = get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_time_cache' ); reset( self::$time_cache ); echo ''; echo '' . esc_html__( 'How often the product cache will be cleared and the prices updated.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_time_cache' ) ); // Adds a settings field for the number of lines displayed for automatic description add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_nb_lines', __( 'Auto description number of lines', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'Number of lines to display for the automatic descriptions.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_nb_lines' ) ); // Adds a settings field for user rights add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_user_right', __( 'Set access role', 'affiliate-ai-lite' ), function() { $option = get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_user_right' ); reset( self::$user_right ); echo ''; echo '' . esc_html__( 'By default you must be an administrator to access the plugin settings. This options lets you change the minimum user role required to access the plugin settings.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_user_right' ) ); // Adds a settings field for disabling the wpautop filter // This option should only be enabled after contacting support add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_wpautop', __( 'Disable the wpautop filter', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'Please contact support before enabling this option.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_wpautop' ) ); // Check if the option for displaying price comparison disclaimers is checked to hide or not the fields if ( empty( get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions' )[0] ) ) { $_ment_hide = ' afx-hidden'; } else { $_ment_hide = ''; } // Adds a settings field for activating the disclaimers about the price comparison add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions', __( 'Show disclaimers under boxes', 'affiliate-ai-lite' ), function() { $_ment_check = ! empty( get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions' )[0] ) ? get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions' )[0] : false; echo ''; echo '' . esc_html__( 'Displays disclaimer information under boxes. It is the responsibility of the site editor to adapt and/or complete these and to comply with the legislation of their country and partners.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions' ) ); // Adds a settings field for custom disclaimers title add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions_title', __( 'Custom disclaimers title', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'If not filled in, the default value will be displayed.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions_title', 'class' => 'afx-ments' . $_ment_hide, ) ); // Adds a settings field for custom disclaimers content add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_mentions_content', __( 'Custom disclaimers content', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'If not filled in, the default value will be displayed.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_content', 'class' => 'afx-ments' . $_ment_hide, ) ); // Adds a settings field for debug mode add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_debug', __( 'Debug mode', 'affiliate-ai-lite' ), function() { echo ''; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_debug' ) ); // Adds a settings field for support code add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_supp_code', __( 'Support code', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'Please contact support before enabling this option.', 'affiliate-ai-lite' ) . '
'; }, 'afx-options', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-advanced', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_supp_code', 'class' => 'afx-supp-code', ) ); // Add a settings section for Amazon merchant add_settings_section( AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', self::$merchants['amazon'], function() { // Add a link to a tutorial on how to get Amazon Tracking ID echo '' . esc_html__( 'Tutorial: How to get your Amazon Tracking ID ?', 'affiliate-ai-lite' ) . ''; }, 'afx-merchant' ); // Add a settings field for Amazon Marketplace add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_country', __( 'Marketplace', 'affiliate-ai-lite' ), function() { echo ''; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_country' ) ); // Add a settings field for Amazon Tracking ID add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_tag', __( 'Tracking ID', 'affiliate-ai-lite' ), function() { echo ''; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_tag' ) ); $class_noaz = ''; add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_creators_key', __( 'Creators API Credential ID', 'affiliate-ai-lite' ), function() { echo ''; echo '' . __( 'Enter the Credential ID for the Amazon Creators API.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_creators_key', 'class' => $class_noaz, ) ); add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_creators_secret', __( 'Creators API Credential Secret', 'affiliate-ai-lite' ), function() { echo ''; echo '' . __( 'Enter the Credential Secret for the Amazon Creators API.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_creators_secret', 'class' => $class_noaz, ) ); // Add a settings field for Amazon Creators API credential version add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_version', __( 'Credential version', 'affiliate-ai-lite' ), function() { $value = trim( get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_version', 'v3' ) ); echo ''; echo '' . __( 'Select the version shown when you generated your Amazon Creators API credentials. New credentials should use v3.x.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_version', 'class' => $class_noaz, ) ); // Add a settings field for Amazon API Key add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_key', __( 'API key (legacy)', 'affiliate-ai-lite' ), function() { echo ''; echo '' . __( 'This is for the the PA API and will be removed shortly since it is being deprecated/retired. Please use/enter your Creators API credentials above instead.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_key', 'class' => $class_noaz, ) ); // Add a settings field for Amazon API Secret add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_secret', __( 'API secret (legacy)', 'affiliate-ai-lite' ), function() { echo ''; echo '' . __( 'This is for the the PA API and will be removed shortly since it is being deprecated/retired. Please use/enter your Creators API credentials above instead.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_api_secret', 'class' => $class_noaz, ) ); // Add a settings field for Amazon Tracking ID "guest" add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_tag_guest', __( 'Tracking ID "guest"', 'affiliate-ai-lite' ), function() { echo ''; echo '' . esc_html__( 'Optional. Lets you assign clicks to an Amazon account other than the one used by the API.', 'affiliate-ai-lite' ) . '
'; echo '' . esc_html__( 'Important: Please save your changes before testing your API key. ↓', 'affiliate-ai-lite' ) . '
'; echo ''; echo ''; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_amazon_tag_guest', 'class' => $class_noaz, ) ); add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_timer_amz', __( 'Reduce frequency of API key queries', 'affiliate-ai-lite' ), function() { echo ' ' . esc_html__( ' If you\'re getting a "429 too many requests" error with your API key, you can activate this option to reduce the frequency of API queries.', 'affiliate-ai-lite' ) . ''; // echo '' . esc_html__( 'You just need to provide your Tracking ID.
Work only with marketplaces: US, UK, FR, ES, DE, IT, JP, IN, CA', 'affiliate-ai-lite' ) . '
' . esc_html__( 'Requires the creation of a new Amazon partner account (and Tracking ID) for each country\'s marketplace you want to use. Redirects the visitor to the Amazon site of their country.', 'affiliate-ai-lite' ) . '
'; echo '' . esc_html__( 'GDPR: In order to determine the country of the visitor, their IP will be sent to a third-party service. If you enable this feature, make sure you are in compliance.', 'affiliate-ai-lite' ) . '
'; echo ''; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_geoip' ) ); // Amazon SiteStripe Converter add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_conv_sst', __( 'SiteStripe Converter', 'affiliate-ai-lite' ), function() { echo ' ' . esc_html__( ' Automatically converts all SiteStripe images or boxes iframes', 'affiliate-ai-lite' ) . ''; echo '' . esc_html__( 'Image conversion is automatic and requires no setting', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_conv_sst' ) ); $class_nosst = 'affiai_h_sst'; if ( checked( get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_conv_sst' ), true, false ) ) { $class_nosst = 'affiai_s_sst'; } add_settings_field( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_sst_choice', __( 'SiteStripe Converter on Homepage & Categories', 'affiliate-ai-lite' ), function() { $choice = get_option( AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_sst_choice' ); if ( empty( $choice ) ) { $choice = array( 'homepage' => 0, 'categories' => 0 ); } echo ' Homepage '; echo ' Categories/Tags/Others Archives'; echo '' . esc_html__( 'By default, sitestripe converter is activated only on posts/pages. You can also activate it on the homepage and on categories/tags with this option.', 'affiliate-ai-lite' ) . '
'; }, 'afx-merchant', AFFIAI_PLUGIN_OPTION_PREFIX . '-shopping-amazon', array( 'label_for' => AFFIAI_PLUGIN_OPTION_PREFIX . '_shopping_sst_choice', 'class' => $class_nosst, ) ); /** * Adds a settings section for the plugin dashboard * The section includes a form with a nonce field, a table view, and a script that selects all checkboxes when the "select all" checkbox is clicked. */ add_settings_section( AFFIAI_PLUGIN_NAME . '-shopping-save', __( 'Dashboard', 'affiliate-ai-lite' ), function() { echo '' . esc_html__( 'Warning: this button will reset all the boxes on the site and some products may disappear if they are no longer available from Amazon.', 'affiliate-ai-lite' ) . '
'; ?>