Plugin Directory

Changeset 3161147


Ignore:
Timestamp:
10/02/2024 01:36:11 AM (18 months ago)
Author:
mvpis
Message:

Updates to better support plugins like Permalinks Manager

Location:
fluentc-translation
Files:
365 added
7 edited

Legend:

Unmodified
Added
Removed
  • fluentc-translation/trunk/fluentc_settings.php

    r3159297 r3161147  
    2828
    2929    <div id="tab-1" class="tab-content current">
     30    <?php do_action( 'fluentc_activation_setup' ); ?>
    3031        <p><?php _e( 'To use FluentC, you need an active subscription.', 'fluentc-translation' ); ?></p>
    3132        <?php if ( $this->fluentc_get_settings() ) { ?>
     
    9091        </form>
    9192        <?php do_action( 'fluentc_admin_tab_three_page' ); ?>
    92         <?php do_action( 'fluentc_activation_setup' ); ?>
     93     
    9394    </div>
    9495
  • fluentc-translation/trunk/fluentc_wordpress_plugin.php

    r3159591 r3161147  
    77 * Plugin URI: https://github.com/fluentc/wordpress-plugin
    88 * Description: A plugin that enables website owners to easily install the FluentC Translation on their WordPress site.
    9  * Version: 1.9.4
     9 * Version: 1.9.5
    1010 * Author: FluentC
    1111 * Author URI: https://www.fluentc.ai
     
    1717define( 'FLUENTC_DIR', __DIR__ );
    1818define( 'FLUENTC_SLUG', 'fluentc_translation' );
    19 define( 'FLUENTC_TRANSLATION_VERSION', "1.9.4" );
     19define( 'FLUENTC_TRANSLATION_VERSION', "1.9.5" );
    2020define( 'FLUENTC_TRANSLATION_PLUGIN_DIR', plugin_dir_path(__FILE__) );
    2121define( 'FLUENTC_TRANSLATION_PLUGIN_URL', plugin_dir_url(__FILE__) );
  • fluentc-translation/trunk/readme.txt

    r3159591 r3161147  
    55Requires at least: 4.6
    66Tested up to: 6.6.2
    7 Stable tag: 1.9.4
     7Stable tag: 1.9.5
    88Requires PHP: 7.3
    99License: GPLv2 or later
  • fluentc-translation/trunk/src/actions/class-admin.php

    r3148988 r3161147  
    1111namespace FluentC\Actions;
    1212
    13 if ( ! defined( 'ABSPATH' ) ) {
    14     exit;
     13if (! defined('ABSPATH') ) {
     14    exit;
    1515}
    1616
     
    2727 * @since 1.2
    2828 */
    29 class Admin implements Hooks {
    30 
    31     /**
    32      * FluentC Widget class
    33      *
    34      * @var object
    35      */
    36     protected $fluentc_widget_c;
    37 
    38     /**
    39      * FluentC Widget class
    40      *
    41      * @var object
    42      */
    43     protected $translations;
    44     /**
    45      * FluentC URL class
    46      *
    47      * @var object
    48      */
    49     protected $fluentc_url;
    50     /**
    51      * FluentC connection class
    52      *
    53      * @var object
    54      */
    55     protected $fluentc_connect;
    56     /**
    57      * FluentC connection class
    58      *
    59      * @var object
    60      */
    61     protected $fluentc_cache;
    62     /**
    63      * Constructor.
    64      *
    65      * @since 1.2
    66      */
    67     public function __construct() {
    68         $this->fluentc_widget_c = new Widget();
    69         $this->fluentc_connect  = new Connect();
    70         $this->fluentc_cache    = new Cache();
    71         $this->fluentc_url      = new Url();
    72         $this->translations = new FluentC_Translations();
    73     }
    74     /**
    75      * Hooks for Autoloading
    76      *
    77      * @since 1.2
    78      */
    79     public function hooks() {
    80         add_action( 'fluentc_admin_settings_page', array( $this, 'get_fluentc_languages' ) );
    81         add_action( 'fluentc_admin_settings_page', array( $this, 'fluentc_admin_get_settings' ) );
    82         add_action( 'fluentc_admin_tab_three_page', array( $this, 'get_cache_form' ) );
    83         add_action( 'fluentc_admin_settings_page_save', array( $this, 'settings_save' ) );
    84         add_action( 'admin_post_fluentc_save_settings_action', array( $this, 'fluentc_admin_save_settings' ) );
    85         add_action( 'admin_post_fluentc_clean_cache_action', array( $this, 'fluentc_admin_clean_cache' ) );
    86         add_action( 'wp_update_nav_menu', array( $this, 'update_menu_cache' ) );
    87         add_action( 'edited_category', array( $this, 'update_menu_cache' ), 10, 2 );
    88         add_action( 'woocommerce_update_product', array( $this, 'update_product_cache' ), 10, 1 );
    89         add_action( 'admin_notices', array( $this, 'check_fluentc_apikey' ), 10, 1 );
    90         add_action( 'admin_enqueue_scripts', array( $this, 'fluentc_apikey_enqueue_script' ), 10, 1 );
    91         add_filter( 'query_vars', array( $this, 'fluentc_var' ), 10, 3 );
    92         add_action( 'wp_ajax_dismiss_fluentc_apikey_warning', array( $this, 'dismiss_fluentc_apikey_warning' ) );
    93         add_action( 'enqueue_block_editor_assets', array( $this, 'fluentc_block_script' ) );
    94         add_action( 'init', array( $this, 'register_fluentc_block' ) );
    95         add_action( 'fluentc_activation_setup', array( $this, 'fluentc_setup' ) );
    96         add_action('init', array( $this, 'integrate_fluentc_languages' ) );
    97         add_action('admin_menu', array($this, 'fluentc_sub_menu'));
     29class Admin implements Hooks
     30{
     31
     32    /**
     33     * FluentC Widget class
     34     *
     35     * @var object
     36     */
     37    protected $fluentc_widget_c;
     38
     39    /**
     40     * FluentC Widget class
     41     *
     42     * @var object
     43     */
     44    protected $translations;
     45    /**
     46     * FluentC URL class
     47     *
     48     * @var object
     49     */
     50    protected $fluentc_url;
     51    /**
     52     * FluentC connection class
     53     *
     54     * @var object
     55     */
     56    protected $fluentc_connect;
     57    /**
     58     * FluentC connection class
     59     *
     60     * @var object
     61     */
     62    protected $fluentc_cache;
     63    /**
     64     * Constructor.
     65     *
     66     * @since 1.2
     67     */
     68    public function __construct()
     69    {
     70        $this->fluentc_widget_c = new Widget();
     71        $this->fluentc_connect  = new Connect();
     72        $this->fluentc_cache    = new Cache();
     73        $this->fluentc_url      = new Url();
     74        $this->translations = new FluentC_Translations();
     75    }
     76    /**
     77     * Hooks for Autoloading
     78     *
     79     * @since 1.2
     80     */
     81    public function hooks()
     82    {
     83        add_action('fluentc_admin_settings_page', array( $this, 'get_fluentc_languages' ));
     84        add_action('fluentc_admin_settings_page', array( $this, 'fluentc_admin_get_settings' ));
     85        add_action('fluentc_admin_tab_three_page', array( $this, 'get_cache_form' ));
     86        add_action('fluentc_admin_settings_page_save', array( $this, 'settings_save' ));
     87        add_action('admin_post_fluentc_save_settings_action', array( $this, 'fluentc_admin_save_settings' ));
     88        add_action('admin_post_fluentc_clean_cache_action', array( $this, 'fluentc_admin_clean_cache' ));
     89        add_action('wp_update_nav_menu', array( $this, 'update_menu_cache' ));
     90        add_action('edited_category', array( $this, 'update_menu_cache' ), 10, 2);
     91        add_action('woocommerce_update_product', array( $this, 'update_product_cache' ), 10, 1);
     92        add_action('admin_notices', array( $this, 'check_fluentc_apikey' ), 10, 1);
     93        add_action('admin_enqueue_scripts', array( $this, 'fluentc_apikey_enqueue_script' ), 10, 1);
     94        add_filter('query_vars', array( $this, 'fluentc_var' ), 10, 3);
     95        add_action('wp_ajax_dismiss_fluentc_apikey_warning', array( $this, 'dismiss_fluentc_apikey_warning' ));
     96        add_action('enqueue_block_editor_assets', array( $this, 'fluentc_block_script' ));
     97        add_action('init', array( $this, 'register_fluentc_block' ));
     98        add_action('fluentc_activation_setup', array( $this, 'fluentc_setup' ));
     99        add_action('init', array( $this, 'integrate_fluentc_languages' ));
     100        add_action('admin_menu', array($this, 'fluentc_sub_menu'));
    98101        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
    99102        add_action('wp_ajax_fluentc_inline_edit', array($this->translations, 'handle_inline_edit'));
    100         add_action('wp_ajax_fluentc_delete_translation', array($this->translations, 'handle_delete_translation'));
    101         add_action('wp_ajax_fluentc_search_translations', array($this->translations, 'handle_search_translations'));
    102         add_action('wp_ajax_fluentc_get_translations', array($this->translations, 'handle_get_translations'));
    103     }
    104     /**
    105      * Set FluentC Vars
    106      *
    107      * @param mixed $vars WordPress vars.
    108      */
    109     public function fluentc_var( $vars ) {
    110         $vars[] = 'fluentc'; // 'fluentc' is the name of path variable.
    111         return $vars;
    112     }
    113 
    114     /**
    115      * Adds a menu item to the WordPress admin dashboard for the plugin settings
    116      */
    117     public function fluentc_sub_menu() {
    118         add_submenu_page('fluentc-settings', 'Edit Translations', 'Edit Translations', 'manage_options', 'fluentc-manage-translations', array($this->translations, 'display_translations_page'));
    119     }
    120 
    121     /**
    122      * Adds scripts to Management Page
    123      */
    124     public function enqueue_admin_scripts($hook) {
     103        add_action('wp_ajax_fluentc_delete_translation', array($this->translations, 'handle_delete_translation'));
     104        add_action('wp_ajax_fluentc_search_translations', array($this->translations, 'handle_search_translations'));
     105        add_action('wp_ajax_fluentc_get_translations', array($this->translations, 'handle_get_translations'));
     106    }
     107    /**
     108     * Set FluentC Vars
     109     *
     110     * @param mixed $vars WordPress vars.
     111     */
     112    public function fluentc_var( $vars )
     113    {
     114        $vars[] = 'fluentc'; // 'fluentc' is the name of path variable.
     115        return $vars;
     116    }
     117
     118    /**
     119     * Adds a menu item to the WordPress admin dashboard for the plugin settings
     120     */
     121    public function fluentc_sub_menu()
     122    {
     123        add_submenu_page('fluentc-settings', 'Edit Translations', 'Edit Translations', 'manage_options', 'fluentc-manage-translations', array($this->translations, 'display_translations_page'));
     124    }
     125
     126    /**
     127     * Adds scripts to Management Page
     128     */
     129    public function enqueue_admin_scripts($hook)
     130    {
    125131   
    126132            $this->translations->enqueue_scripts();
    127133   
    128134    }
    129     /**
    130      * GET from fluentc.ai
    131      */
    132     public function fluentc_admin_get_settings() {
    133         if ( isset( $_GET['fluentc'] ) ) {
    134             $api_key = sanitize_text_field( wp_unslash( $_GET['fluentc'] ) );
    135             $this->save_settings( $api_key );
    136             $this->fluentc_cache->clean();
    137             wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) );
    138             exit;
    139         }
    140     }
    141     /**
    142      * Save Function sanitize_text_field( wp_unslash( $_POST['faq_highlighted'] ) )
    143      */
    144     public function fluentc_admin_save_settings() {
    145         if ( isset( $_POST['submit'] ) ) {
    146             if ( isset( $_POST['fluentc_settings_nonce_field'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['fluentc_settings_nonce_field'] ) ), 'fluentc_save_settings_action' ) ) {
    147                 try {
    148                     $api_key = isset( $_POST['fluentc_api_key'] ) ? sanitize_text_field( wp_unslash( $_POST['fluentc_api_key'] ) ) : '';
    149                     $this->save_settings( $api_key );
    150                     add_settings_error( 'fluentc-settings', 'fluentc_api_key_saved', 'FluentC API key saved.', 'updated' );
    151                     do_action( 'fluentc_admin_settings_page_save' );
    152                     wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) );
    153                     exit;
    154                 } catch ( \Exception $e ) {
    155                     add_settings_error( 'fluentc-settings', 'fluentc_api_key_error', 'Error saving FluentC API key: ' . $e->getMessage(), 'error' );
    156                 }
    157             } else {
    158                 // Handle the case where the nonce check fails.
    159                 wp_die( 'Security check failed' );
    160             }
    161         }
    162     }
    163     /**
    164      * Empty Cache
    165      */
    166     public function fluentc_admin_clean_cache() {
    167         $clean_cache_nonce_field = sanitize_text_field( wp_unslash( $_POST['fluentc_clean_cache_nonce_field'] ?? null ) );
    168 
    169         if ( isset( $_POST['submit'] ) && isset( $clean_cache_nonce_field ) && wp_verify_nonce( $clean_cache_nonce_field, 'fluentc_clean_cache_action' ) ) {
    170             try {
    171                 $this->fluentc_cache->clean();
    172                 do_action( 'fluentc_admin_clean_cache' );
    173                 wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) );
    174                 exit;
    175             } catch ( \Exception $e ) {
    176                 add_settings_error( 'fluentc-settings', 'fluentc_api_key_error', 'Error Clearing Cache: ' . $e->getMessage(), 'error' );
    177             }
    178         } else {
    179             // Handle the case where the nonce check fails.
    180             wp_die( 'Security check failed' );
    181         }
    182     }
    183     /**
    184      * Sets up the FluentC account
    185      *
    186      *
    187      */
    188     public function fluentc_setup( ) {
    189 
    190         $widgetapikey = get_option( 'fluentc_api_key' );
    191 
    192         $this->fluentc_connect->heartbeat($widgetapikey);
    193    
    194     }
    195 
    196     /**
    197      * Saves the user's FluentC API key to the WordPress database
    198      *
    199      * @param string $api_key FluentC Key.
    200      */
    201     public function save_settings( $api_key ) {
    202 
    203         update_option( 'fluentc_api_key', $api_key );
    204     }
    205 
    206     /**
    207      * Update all cache when the menu is updated
    208      */
    209     public function update_menu_cache() {
    210 
    211         $this->fluentc_cache->clean();
    212     }
    213 
    214     /**
    215      * Update all cache when the category is updated
    216      *
    217      * @param int $term_id taxonomy term.
    218      * @param int $tt_id ttid.
    219      */
    220     public function update_category_cache( $term_id, $tt_id ) {
    221 
    222         $this->fluentc_cache->clean();
    223     }
    224 
    225     /**
    226      * Update all cache when the product is updated
    227      *
    228      * @param int $product_id id of the product.
    229      */
    230     public function update_product_cache( $product_id ) {
    231 
    232         // getall Language combinations.
    233         $this->fluentc_cache->clean();
    234     }
    235     /**
    236      * Update all cache when the pages and post is updated
    237      *
    238      * @param int $id id of the post.
    239      */
    240     public function update_post_and_pages( $id ) {
    241         // Loop.
    242         // Source Lang . dispalyLange[1] . id.
    243         // Add_action publish_page.
    244         // add_action publish_pust.
    245         // Update the cache when a post is saved.
    246         $this->fluentc_cache->clean();
    247     }
    248     /**
    249      * GetFluentCLanguages and return them in table form
    250      */
    251     public function get_fluentc_languages() {
    252         $widgetapikey = get_option( 'fluentc_api_key' );
    253         if ( $widgetapikey ) {
    254             ?>
    255             <table class="wp-list-table widefat fixed">
    256                 <thead>
    257                     <tr>
    258                         <td class="column-primary">Language</td>
    259                         <td class="column-name">Language Code</td>
    260                     </tr>
    261                 </thead>
    262                 <tbody>
    263                     <?php
    264                     $languages = $this->fluentc_connect->get_display_language_list( $widgetapikey );
    265 
    266                     foreach ( $languages as $language ) {
    267                         ?>
    268                         <tr>
    269                             <td>
    270                                 <?php echo esc_html( $language[0] ); ?>
    271                             </td>
    272                             <td>
    273                                 <?php echo esc_html( $language[1] ); ?>
    274                             </td>
    275                         </tr>
    276                         <?php
    277                     }
    278                     ?>
    279                 </tbody>
    280             </table>
    281             <?php
    282         } else {
    283             echo esc_html( 'FluentC API Key Not Set' );
    284         }
    285        
    286     }
    287 
    288     /**
    289      * Return the Cache form
    290      */
    291     public function get_cache_form() {
    292         $action_url = esc_url( admin_url( 'admin-post.php' ) );
    293 
    294         ?>
    295         <hr />
    296         <h3>If you have made changes at FluentC.ai, Clearing Cache will update</h3>
    297         <form method="post" action='<?php echo esc_html( $action_url ); ?>'>
    298 
    299             <?php
    300             // Directly call wp_nonce_field to output its content.
    301             wp_nonce_field( 'fluentc_clean_cache_action', 'fluentc_clean_cache_nonce_field' );
    302             ?>
    303             <input type="hidden" name="action" value="fluentc_clean_cache_action">
    304             <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Clear Cache">
    305             </p>
    306         </form>
    307         <h3>FluentC API Calls : <?php $apicalls = $this->fluentc_cache->get('apicalls'); echo esc_html( $apicalls ); ?></h3>
    308         <?php
    309     }
    310 
    311     /**
    312      * Check if API Key is set
    313      */
    314     public function check_fluentc_apikey() {
    315         // Check if the user has dismissed the notice and if the dismissal period is still active.
    316         if ( get_transient( 'fluentc_apikey_dismissed' ) ) {
    317             return;
    318         }
    319 
    320         // Check if the API key is stored in the settings.
    321         $widgetapikey = get_option( 'fluentc_api_key' );
    322         if ( empty( $widgetapikey ) ) {
    323             ?>
    324             <div class="notice notice-warning is-dismissible">
    325             <?php _e( '<p><strong>FluentC API Key is missing.</strong> Please add your API key in settings to use the FluentC features.</p>', 'fluentc-translation' ); ?>
    326             </div>
    327             <?php
    328             add_action( 'admin_notices', array( $this, 'fluentc_apikey_enqueue_script' ), 10, 1 );
    329         }
    330     }
    331 
    332     /**
    333      * Script to update API Notice dismiss
    334      */
    335     public function fluentc_apikey_enqueue_script() {
    336         // Register the script.
    337         wp_register_script( 'fluentc-apikey-script', null ); // Use 'null' if you're not using an external JS file.
    338         wp_add_inline_script(
    339             'fluentc-apikey-script',
    340             '
     135    /**
     136     * GET from fluentc.ai
     137     */
     138    public function fluentc_admin_get_settings()
     139    {
     140        if (isset($_GET['fluentc']) ) {
     141            $api_key = sanitize_text_field(wp_unslash($_GET['fluentc']));
     142            $this->save_settings($api_key);
     143            $this->fluentc_cache->clean();
     144            wp_safe_redirect(admin_url('admin.php?page=fluentc-settings'));
     145            exit;
     146        }
     147    }
     148    /**
     149     * Save Function sanitize_text_field( wp_unslash( $_POST['faq_highlighted'] ) )
     150     */
     151    public function fluentc_admin_save_settings()
     152    {
     153        if (isset($_POST['submit']) ) {
     154            if (isset($_POST['fluentc_settings_nonce_field']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['fluentc_settings_nonce_field'])), 'fluentc_save_settings_action') ) {
     155                try {
     156                    $api_key = isset($_POST['fluentc_api_key']) ? sanitize_text_field(wp_unslash($_POST['fluentc_api_key'])) : '';
     157                    $this->save_settings($api_key);
     158                    add_settings_error('fluentc-settings', 'fluentc_api_key_saved', 'FluentC API key saved.', 'updated');
     159                    do_action('fluentc_admin_settings_page_save');
     160                    wp_safe_redirect(admin_url('admin.php?page=fluentc-settings'));
     161                    exit;
     162                } catch ( \Exception $e ) {
     163                    add_settings_error('fluentc-settings', 'fluentc_api_key_error', 'Error saving FluentC API key: ' . $e->getMessage(), 'error');
     164                }
     165            } else {
     166                // Handle the case where the nonce check fails.
     167                wp_die('Security check failed');
     168            }
     169        }
     170    }
     171    /**
     172     * Empty Cache
     173     */
     174    public function fluentc_admin_clean_cache()
     175    {
     176        $clean_cache_nonce_field = sanitize_text_field(wp_unslash($_POST['fluentc_clean_cache_nonce_field'] ?? null));
     177
     178        if (isset($_POST['submit']) && isset($clean_cache_nonce_field) && wp_verify_nonce($clean_cache_nonce_field, 'fluentc_clean_cache_action') ) {
     179            try {
     180                $this->fluentc_cache->clean();
     181                do_action('fluentc_admin_clean_cache');
     182                wp_safe_redirect(admin_url('admin.php?page=fluentc-settings'));
     183                exit;
     184            } catch ( \Exception $e ) {
     185                add_settings_error('fluentc-settings', 'fluentc_api_key_error', 'Error Clearing Cache: ' . $e->getMessage(), 'error');
     186            }
     187        } else {
     188            // Handle the case where the nonce check fails.
     189            wp_die('Security check failed');
     190        }
     191    }
     192    /**
     193     * Sets up the FluentC account
     194     */
     195    public function fluentc_setup( )
     196    {
     197
     198        $widgetapikey = get_option('fluentc_api_key');
     199
     200        $this->fluentc_connect->heartbeat($widgetapikey);
     201   
     202    }
     203
     204    /**
     205     * Saves the user's FluentC API key to the WordPress database
     206     *
     207     * @param string $api_key FluentC Key.
     208     */
     209    public function save_settings( $api_key )
     210    {
     211
     212        update_option('fluentc_api_key', $api_key);
     213    }
     214
     215    /**
     216     * Update all cache when the menu is updated
     217     */
     218    public function update_menu_cache()
     219    {
     220
     221        $this->fluentc_cache->clean();
     222    }
     223
     224    /**
     225     * Update all cache when the category is updated
     226     *
     227     * @param int $term_id taxonomy term.
     228     * @param int $tt_id   ttid.
     229     */
     230    public function update_category_cache( $term_id, $tt_id )
     231    {
     232
     233        $this->fluentc_cache->clean();
     234    }
     235
     236    /**
     237     * Update all cache when the product is updated
     238     *
     239     * @param int $product_id id of the product.
     240     */
     241    public function update_product_cache( $product_id )
     242    {
     243
     244        // getall Language combinations.
     245        $this->fluentc_cache->clean();
     246    }
     247    /**
     248     * Update all cache when the pages and post is updated
     249     *
     250     * @param int $id id of the post.
     251     */
     252    public function update_post_and_pages( $id )
     253    {
     254        // Loop.
     255        // Source Lang . dispalyLange[1] . id.
     256        // Add_action publish_page.
     257        // add_action publish_pust.
     258        // Update the cache when a post is saved.
     259        $this->fluentc_cache->clean();
     260    }
     261    /**
     262     * GetFluentCLanguages and return them in table form
     263     */
     264    public function get_fluentc_languages()
     265    {
     266        $widgetapikey = get_option('fluentc_api_key');
     267        if ($widgetapikey ) {
     268            ?>
     269            <table class="wp-list-table widefat fixed">
     270                <thead>
     271                    <tr>
     272                        <td class="column-primary">Language</td>
     273                        <td class="column-name">Language Code</td>
     274                    </tr>
     275                </thead>
     276                <tbody>
     277            <?php
     278            $languages = $this->fluentc_connect->get_display_language_list($widgetapikey);
     279
     280            foreach ( $languages as $language ) {
     281                ?>
     282                        <tr>
     283                            <td>
     284                <?php echo esc_html($language[0]); ?>
     285                            </td>
     286                            <td>
     287                <?php echo esc_html($language[1]); ?>
     288                            </td>
     289                        </tr>
     290                <?php
     291            }
     292            ?>
     293                </tbody>
     294            </table>
     295            <?php
     296        } else {
     297            echo esc_html('FluentC API Key Not Set');
     298        }
     299       
     300    }
     301
     302    /**
     303     * Return the Cache form
     304     */
     305    public function get_cache_form()
     306    {
     307        $action_url = esc_url(admin_url('admin-post.php'));
     308
     309        ?>
     310        <hr />
     311        <h3>If you have made changes at FluentC.ai, Clearing Cache will update</h3>
     312        <form method="post" action='<?php echo esc_html($action_url); ?>'>
     313
     314        <?php
     315        // Directly call wp_nonce_field to output its content.
     316        wp_nonce_field('fluentc_clean_cache_action', 'fluentc_clean_cache_nonce_field');
     317        ?>
     318            <input type="hidden" name="action" value="fluentc_clean_cache_action">
     319            <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Clear Cache">
     320            </p>
     321        </form>
     322        <h3>FluentC API Calls : <?php $apicalls = $this->fluentc_cache->get('apicalls'); echo esc_html($apicalls); ?></h3>
     323        <?php
     324    }
     325
     326    /**
     327     * Check if API Key is set
     328     */
     329    public function check_fluentc_apikey()
     330    {
     331        // Check if the user has dismissed the notice and if the dismissal period is still active.
     332        if (get_transient('fluentc_apikey_dismissed') ) {
     333            return;
     334        }
     335
     336        // Check if the API key is stored in the settings.
     337        $widgetapikey = get_option('fluentc_api_key');
     338        if (empty($widgetapikey) ) {
     339            ?>
     340            <div class="notice notice-warning is-dismissible">
     341            <?php _e('<p><strong>FluentC API Key is missing.</strong> Please add your API key in settings to use the FluentC features.</p>', 'fluentc-translation'); ?>
     342            </div>
     343            <?php
     344            add_action('admin_notices', array( $this, 'fluentc_apikey_enqueue_script' ), 10, 1);
     345        }
     346    }
     347
     348    /**
     349     * Script to update API Notice dismiss
     350     */
     351    public function fluentc_apikey_enqueue_script()
     352    {
     353        // Register the script.
     354        wp_register_script('fluentc-apikey-script', null); // Use 'null' if you're not using an external JS file.
     355        wp_add_inline_script(
     356            'fluentc-apikey-script',
     357            '
    341358            jQuery(document).ready(function($) {
    342359                $(document).on("click", ".notice-warning.is-dismissible button.notice-dismiss", function() {
     
    347364            });
    348365        '
    349         );
    350         // Enqueue the script.
    351         wp_enqueue_script( 'fluentc-apikey-script' );
    352     }
    353     /**
    354      * Set transient to dismiss message for 7 days
    355      */
    356     public function dismiss_fluentc_apikey_warning() {
    357         // Set a transient for 7 days.
    358         set_transient( 'fluentc_apikey_dismissed', 'yes', 7 * DAY_IN_SECONDS );
    359         wp_die(); // This is required to terminate immediately and return a proper response.
    360     }
    361 
    362     /**
    363      * Handle the saving settings
    364      */
    365     public function settings_save() {
    366         // Validate Widget Key.
    367         $widgetapikey = get_option( 'fluentc_api_key' );
    368         $languages    = $this->fluentc_connect->get_display_language_list( $widgetapikey );
    369         if ( $languages ) {
    370             wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) );
    371             exit;
    372         } else {
    373             echo esc_html( '<strong>Widget has no languages setup, please visit FluentC and enable a language to translate</strong>' );
    374         }
    375     }
    376 
    377     // Register the block script.
    378     public function fluentc_block_script() {
    379         wp_enqueue_script( 'fluentc-block-script', plugins_url( '/include/script.js', __FILE__ ), array( 'wp-blocks' ), '1.0', true );
    380     }
    381 
    382 
    383     // Register the Block.
    384     public function register_fluentc_block() {
    385         register_block_type(
    386             'fluentc/fluentc-block',
    387             array(
    388                 'editor_script'   => 'fluentc-block-script',
    389                 'render_callback' => 'fluentc_block_render_callback',
    390             )
    391         );
    392     }
    393 
    394     // Render Callback Function
    395     public function fluentc_block_render_callback( $attributes ) {
    396         return '<div id="fluentc-widget"></div>';
    397     }
    398 
    399     /**
    400  * Retrieve Available Language by Site Key and Insert into WordPress
    401  *
    402  * @return void
    403  * @since  1.2
    404  * @param  string $environment_id FluentC Environment ID.
    405  */
    406 public function integrate_fluentc_languages( ) {
    407     $widgetapikey = get_option( 'fluentc_api_key' );
    408     $languages = $this->fluentc_connect->get_display_language_list( $widgetapikey );
    409 
    410     if (is_null($languages)) {
    411         return;
    412     }
    413     foreach ($languages as $language) {
     366        );
     367        // Enqueue the script.
     368        wp_enqueue_script('fluentc-apikey-script');
     369    }
     370    /**
     371     * Set transient to dismiss message for 7 days
     372     */
     373    public function dismiss_fluentc_apikey_warning()
     374    {
     375        // Set a transient for 7 days.
     376        set_transient('fluentc_apikey_dismissed', 'yes', 7 * DAY_IN_SECONDS);
     377        wp_die(); // This is required to terminate immediately and return a proper response.
     378    }
     379
     380    /**
     381     * Handle the saving settings
     382     */
     383    public function settings_save()
     384    {
     385        // Validate Widget Key.
     386        $widgetapikey = get_option('fluentc_api_key');
     387        $languages    = $this->fluentc_connect->get_display_language_list($widgetapikey);
     388        if ($languages ) {
     389            wp_safe_redirect(admin_url('admin.php?page=fluentc-settings'));
     390            exit;
     391        } else {
     392            echo esc_html('<strong>Widget has no languages setup, please visit FluentC and enable a language to translate</strong>');
     393        }
     394    }
     395
     396    // Register the block script.
     397    public function fluentc_block_script()
     398    {
     399        wp_enqueue_script('fluentc-block-script', plugins_url('/include/script.js', __FILE__), array( 'wp-blocks' ), '1.0', true);
     400    }
     401
     402
     403    // Register the Block.
     404    public function register_fluentc_block()
     405    {
     406        register_block_type(
     407            'fluentc/fluentc-block',
     408            array(
     409            'editor_script'   => 'fluentc-block-script',
     410            'render_callback' => 'fluentc_block_render_callback',
     411            )
     412        );
     413    }
     414
     415    // Render Callback Function
     416    public function fluentc_block_render_callback( $attributes )
     417    {
     418        return '<div id="fluentc-widget"></div>';
     419    }
     420
     421    /**
     422     * Retrieve Available Language by Site Key and Insert into WordPress
     423     *
     424     * @return void
     425     * @since  1.2
     426     * @param  string $environment_id FluentC Environment ID.
     427     */
     428    public function integrate_fluentc_languages( )
     429    {
     430        $widgetapikey = get_option('fluentc_api_key');
     431        $languages = $this->fluentc_connect->get_display_language_list($widgetapikey);
     432
     433        if (is_null($languages)) {
     434            return;
     435        }
     436        foreach ($languages as $language) {
    414437            $name = $language[0];
    415438            $slug = $language[1];
     
    421444        }
    422445   
     446    }
    423447}
    424 }
  • fluentc-translation/trunk/src/actions/class-links.php

    r3122693 r3161147  
    55 * This file contains the WordPress functions for updating Permalinks and Routes
    66 *
    7  * @package FluentCPlugin
    8  * @author  FluentC <wp@fluentc.io>
    97 */
    108
    119namespace FluentC\Actions;
    1210
    13 if ( ! defined( 'ABSPATH' ) ) {
    14     exit;
     11if (! defined('ABSPATH') ) {
     12    exit;
    1513}
    1614
     
    2220 *  Permalinks Actions
    2321 */
    24 class Links implements Hooks {
    25 
    26 
    27     /**
    28      * FluentC connection class
    29      *
    30      * @var object
    31      */
    32     protected $fluentc_connect;
    33     /**
    34      * FluentC connection class
    35      *
    36      * @var object
    37      */
    38     protected $fluentc_language;
    39 
    40     /**
    41      * Constructor.
    42      *
    43      * @since 1.2
    44      */
    45     public function __construct() {
    46 
    47         $this->fluentc_connect  = new Connect();
    48         $this->fluentc_language = new Language();
    49     }
    50     /**
    51      * Hooks for Autoloading
    52      *
    53      * @since 1.2
    54      */
    55     public function hooks() {
    56         add_action( 'wp', array( $this, 'add_language_code_to_home_url_later' ) );
    57         add_filter( 'woocommerce_get_cart_url', array( $this, 'add_language_code_to_cart_url' ), 10, 1 );
    58         add_filter( 'query_vars', array( $this, 'language_var' ), 10, 3 );
    59         add_action( 'init', array( $this, 'flush_rewrite' ), 1000 );
    60         add_filter( 'rewrite_rules_array', array( $this, 'fluentc_rewrite_rules' ), 100 );
    61     }
    62 
    63     /**
    64      * HomeLink that filters after wp is ready.
    65      */
    66     public function add_language_code_to_home_url_later() {
    67         add_filter( 'home_url', array( $this, 'add_language_code_to_home_url' ), 10, 4 );
    68     }
    69 
    70     /**
    71      * Updates Home page link
    72      *
    73      * @param  string $url url.
    74      * @param  string $path path.
    75      * @param  string $orig_scheme orig_scheme.
    76      * @param  string $blog_id blog_id.
    77      */
    78     public function add_language_code_to_home_url($url, $path, $orig_scheme, $blog_id) {
    79         // Assuming you have a function that returns the current language code.
    80         $language_code = $this->fluentc_language->get_fluentc_language();
    81    
    82         // If there's no language code, return the original URL.
    83         if (empty($language_code)) {
    84             return $url;
    85         }
    86    
    87         // Modify the home URL to add the language code.
    88         $url_parts = wp_parse_url($url);
    89    
    90         // Ensure the necessary parts exist.
    91         $scheme = isset($url_parts['scheme']) ? $url_parts['scheme'] : 'http';
    92         $host = isset($url_parts['host']) ? $url_parts['host'] : '';
    93         $existing_path = isset($url_parts['path']) ? $url_parts['path'] : '';
    94    
    95         // Ensure the path includes the leading '/'.
    96         $modified_path = '/' . trim($language_code . '/' . ltrim($existing_path, '/'), '/');
    97    
    98         // Rebuild the URL with the language code.
    99         $new_url = $scheme . '://' . $host . $modified_path;
    100         if (!empty($url_parts['query'])) {
    101             $new_url .= '?' . $url_parts['query'];
    102         }
    103         if (!empty($url_parts['fragment'])) {
    104             $new_url .= '#' . $url_parts['fragment'];
    105         }
    106    
    107         return $new_url;
    108     }
    109 
    110     /**
    111      * Updates Permalinks
    112      *
    113      * @param  string $permalink permalink.
    114      * @param  string $post post.
    115      */
    116     public function add_language_code_to_post( $permalink, $post ) {
    117         // Assuming you have a function that returns the current language code.
    118         $language_code = $this->fluentc_language->get_fluentc_language();
    119 
    120         // If there's no language code, return the original permalink.
    121         if ( empty( $language_code ) ) {
    122             return $permalink;
    123         }
    124 
    125         // Modify the permalink to add the language code.
    126         $url_parts = wp_parse_url( $permalink );
    127         $path      = '/' . $language_code . $url_parts['path'];
    128 
    129         // Rebuild the URL with the language code.
    130         $new_permalink = $url_parts['scheme'] . '://' . $url_parts['host'] . $path;
    131         if ( ! empty( $url_parts['query'] ) ) {
    132             $new_permalink .= '?' . $url_parts['query'];
    133         }
    134         if ( ! empty( $url_parts['fragment'] ) ) {
    135             $new_permalink .= '#' . $url_parts['fragment'];
    136         }
    137 
    138         return $new_permalink;
    139     }
    140 
    141     /**
    142      * Updates Permalink for Cart Link
    143      *
    144      * @param  string $cart_url cart_url .
    145      */
    146     public function add_language_code_to_cart_url( $cart_url ) {
    147         // Assuming you have a function that returns the current language code.
    148         $language_code = $this->fluentc_language->get_fluentc_language();
    149 
    150         // If there's no language code, return the original cart URL.
    151         if ( empty( $language_code ) ) {
    152             return $cart_url;
    153         }
    154 
    155         // Modify the cart URL to add the language code.
    156         $url_parts = wp_parse_url( $cart_url );
    157         // Ensure the path includes the leading '/'.
    158         $modified_path = '/' . trim( $language_code . '/' . ltrim( $url_parts['path'], '/' ), '/' );
    159 
    160         // Rebuild the URL with the language code.
    161         $new_cart_url = $url_parts['scheme'] . '://' . $url_parts['host'] . $modified_path;
    162         if ( ! empty( $url_parts['query'] ) ) {
    163             $new_cart_url .= '?' . $url_parts['query'];
    164         }
    165         if ( ! empty( $url_parts['fragment'] ) ) {
    166             $new_cart_url .= '#' . $url_parts['fragment'];
    167         }
    168 
    169         return $new_cart_url;
    170     }
    171 
    172     /**
    173      * Updates Permalinks
    174      *
    175      * @param  string $permalink permalink.
    176      * @param  string $post post.
    177      */
    178     public function add_language_code_to_permalink( $permalink, $post ) {
    179         // Assuming you have a function that returns the current language code.
    180         $language_code = $this->fluentc_language->get_fluentc_language();
    181 
    182         // If there's no language code, return the original permalink.
    183         if ( empty( $language_code ) ) {
    184             return $permalink;
    185         }
    186 
    187         // Modify the permalink to add the language code.
    188         $url_parts = wp_parse_url( $permalink );
    189         $path      = '/' . $language_code . $url_parts['path'];
    190 
    191         // Rebuild the URL with the language code.
    192         $new_permalink = $url_parts['scheme'] . '://' . $url_parts['host'] . $path;
    193         if ( ! empty( $url_parts['query'] ) ) {
    194             $new_permalink .= '?' . $url_parts['query'];
    195         }
    196         if ( ! empty( $url_parts['fragment'] ) ) {
    197             $new_permalink .= '#' . $url_parts['fragment'];
    198         }
    199 
    200         return $new_permalink;
    201     }
    202 
    203     /**
    204      * Updates Flush ReWrite Rules
    205      */
    206     public function flush_rewrite() {
    207         flush_rewrite_rules();
    208     }
    209 
    210     /**
    211      * Adds Language Var
    212      *
    213      * @param  array $vars All WordPress Vars.
    214      */
    215     public function language_var( $vars ) {
    216         $vars[] = 'fluentc_language'; // 'fluentc_language' is the name of path variable.
    217         return $vars;
    218     }
    219 
    220     /**
    221      * Updates ReWriteRules
    222      *
    223      * @param mixed $rules WordPress rewrite rules.
    224      */
    225     public function fluentc_rewrite_rules( $rules ) {
    226 
    227         $new_rules                                 = array();
    228         $widget_id                                 = get_option( 'fluentc_api_key' );
    229         $regex_lang                                = $this->fluentc_connect->get_language_list_string( $widget_id );
    230         $new_rules[ '(?:' . $regex_lang . ')/?$' ] = 'index.php';
    231 
    232         $languages = $this->fluentc_connect->get_language_list( $widget_id );
    233         foreach ( $rules as $key => $val ) {
    234 
    235             if ( $languages ) {
    236                 // For Pretty Permalinks.
    237                 foreach ( $languages as $language ) {
    238                     // Add language codes to existing rewrite rules.
    239                     ${"new_key_$language"} = '(?:' . $language . ')/?' . ltrim( $key, '^' );
    240 
    241                     // Add rules for each language.
    242                     $new_rules[ ${"new_key_$language"} ] = $val;
    243 
    244                 }
    245             }
    246             // Retain the original rule without the language code prefix.
    247             $new_rules[ $key ] = $val;
    248         }
    249 
    250         return $new_rules;
    251     }
     22class Links implements Hooks
     23{
     24
     25
     26    /**
     27     * FluentC connection class
     28     *
     29     * @var object
     30     */
     31    protected $fluentc_connect;
     32    /**
     33     * FluentC connection class
     34     *
     35     * @var object
     36     */
     37    protected $fluentc_language;
     38
     39    /**
     40     * Constructor.
     41     *
     42     * @since 1.2
     43     */
     44    public function __construct()
     45    {
     46
     47        $this->fluentc_connect  = new Connect();
     48        $this->fluentc_language = new Language();
     49    }
     50    /**
     51     * Hooks for Autoloading
     52     *
     53     * @since 1.2
     54     */
     55    public function hooks()
     56    {
     57        add_action('wp', array( $this, 'add_language_code_to_home_url_later' ));
     58        add_filter('woocommerce_get_cart_url', array( $this, 'add_language_code_to_cart_url' ), 10, 1);
     59        add_filter('query_vars', array( $this, 'language_var' ), 10, 3);
     60        add_action('init', array( $this, 'flush_rewrite' ), 1000);
     61        add_filter('rewrite_rules_array', array( $this, 'fluentc_rewrite_rules' ), 100);
     62    }
     63
     64    /**
     65     * HomeLink that filters after wp is ready.
     66     */
     67    public function add_language_code_to_home_url_later()
     68    {
     69        add_filter('home_url', array( $this, 'add_language_code_to_home_url' ), 10, 4);
     70    }
     71
     72    /**
     73     * Updates Home page link
     74     *
     75     * @param string $url         url.
     76     * @param string $path        path.
     77     * @param string $orig_scheme orig_scheme.
     78     * @param string $blog_id     blog_id.
     79     */
     80    public function add_language_code_to_home_url($url, $path, $orig_scheme, $blog_id)
     81    {
     82        // Assuming you have a function that returns the current language code.
     83        $language_code = $this->fluentc_language->get_fluentc_language();
     84   
     85        // If there's no language code, return the original URL.
     86        if (empty($language_code)) {
     87            return $url;
     88        }
     89   
     90        // Modify the home URL to add the language code.
     91        $url_parts = wp_parse_url($url);
     92   
     93        // Ensure the necessary parts exist.
     94        $scheme = isset($url_parts['scheme']) ? $url_parts['scheme'] : 'http';
     95        $host = isset($url_parts['host']) ? $url_parts['host'] : '';
     96        $existing_path = isset($url_parts['path']) ? $url_parts['path'] : '';
     97   
     98        // Ensure the path includes the leading '/'.
     99        $modified_path = '/' . trim($language_code . '/' . ltrim($existing_path, '/'), '/');
     100   
     101        // Rebuild the URL with the language code.
     102        $new_url = $scheme . '://' . $host . $modified_path;
     103        if (!empty($url_parts['query'])) {
     104            $new_url .= '?' . $url_parts['query'];
     105        }
     106        if (!empty($url_parts['fragment'])) {
     107            $new_url .= '#' . $url_parts['fragment'];
     108        }
     109   
     110        return $new_url;
     111    }
     112
     113    /**
     114     * Updates Permalinks
     115     *
     116     * @param string $permalink permalink.
     117     * @param string $post      post.
     118     */
     119    public function add_language_code_to_post( $permalink, $post )
     120    {
     121        // Assuming you have a function that returns the current language code.
     122        $language_code = $this->fluentc_language->get_fluentc_language();
     123
     124        // If there's no language code, return the original permalink.
     125        if (empty($language_code) ) {
     126            return $permalink;
     127        }
     128
     129        // Modify the permalink to add the language code.
     130        $url_parts = wp_parse_url($permalink);
     131        $path      = '/' . $language_code . $url_parts['path'];
     132
     133        // Rebuild the URL with the language code.
     134        $new_permalink = $url_parts['scheme'] . '://' . $url_parts['host'] . $path;
     135        if (! empty($url_parts['query']) ) {
     136            $new_permalink .= '?' . $url_parts['query'];
     137        }
     138        if (! empty($url_parts['fragment']) ) {
     139            $new_permalink .= '#' . $url_parts['fragment'];
     140        }
     141
     142        return $new_permalink;
     143    }
     144
     145    /**
     146     * Updates Permalink for Cart Link
     147     *
     148     * @param string $cart_url cart_url .
     149     */
     150    public function add_language_code_to_cart_url( $cart_url )
     151    {
     152        // Assuming you have a function that returns the current language code.
     153        $language_code = $this->fluentc_language->get_fluentc_language();
     154
     155        // If there's no language code, return the original cart URL.
     156        if (empty($language_code) ) {
     157            return $cart_url;
     158        }
     159
     160        // Modify the cart URL to add the language code.
     161        $url_parts = wp_parse_url($cart_url);
     162        // Ensure the path includes the leading '/'.
     163        $modified_path = '/' . trim($language_code . '/' . ltrim($url_parts['path'], '/'), '/');
     164
     165        // Rebuild the URL with the language code.
     166        $new_cart_url = $url_parts['scheme'] . '://' . $url_parts['host'] . $modified_path;
     167        if (! empty($url_parts['query']) ) {
     168            $new_cart_url .= '?' . $url_parts['query'];
     169        }
     170        if (! empty($url_parts['fragment']) ) {
     171            $new_cart_url .= '#' . $url_parts['fragment'];
     172        }
     173
     174        return $new_cart_url;
     175    }
     176
     177    /**
     178     * Updates Permalinks
     179     *
     180     * @param string $permalink permalink.
     181     * @param string $post      post.
     182     */
     183    public function add_language_code_to_permalink( $permalink, $post )
     184    {
     185        // Assuming you have a function that returns the current language code.
     186        $language_code = $this->fluentc_language->get_fluentc_language();
     187
     188        // If there's no language code, return the original permalink.
     189        if (empty($language_code) ) {
     190            return $permalink;
     191        }
     192
     193        // Modify the permalink to add the language code.
     194        $url_parts = wp_parse_url($permalink);
     195        $path      = '/' . $language_code . $url_parts['path'];
     196
     197        // Rebuild the URL with the language code.
     198        $new_permalink = $url_parts['scheme'] . '://' . $url_parts['host'] . $path;
     199        if (! empty($url_parts['query']) ) {
     200            $new_permalink .= '?' . $url_parts['query'];
     201        }
     202        if (! empty($url_parts['fragment']) ) {
     203            $new_permalink .= '#' . $url_parts['fragment'];
     204        }
     205
     206        return $new_permalink;
     207    }
     208
     209    /**
     210     * Updates Flush ReWrite Rules
     211     */
     212    public function flush_rewrite()
     213    {
     214        flush_rewrite_rules();
     215    }
     216
     217    /**
     218     * Adds Language Var
     219     *
     220     * @param array $vars All WordPress Vars.
     221     */
     222    public function language_var( $vars )
     223    {
     224        $vars[] = 'fluentc_language'; // 'fluentc_language' is the name of path variable.
     225        return $vars;
     226    }
     227
     228    /**
     229     * Updates ReWriteRules
     230     *
     231     * @param mixed $rules WordPress rewrite rules.
     232     */
     233    public function fluentc_rewrite_rules( $rules )
     234    {
     235
     236        $new_rules                                 = array();
     237        $widget_id                                 = get_option('fluentc_api_key');
     238        if (!$widget_id ) {
     239            return;
     240        }
     241        $regex_lang = $this->fluentc_connect->get_language_list_string($widget_id);
     242        if (!$regex_lang  ) {
     243            return;
     244        }
     245        $new_rules[ '(?:' . $regex_lang . ')/?$' ] = 'index.php';
     246
     247        $languages = $this->fluentc_connect->get_language_list($widget_id);
     248        foreach ( $rules as $key => $val ) {
     249
     250            if ($languages ) {
     251                // For Pretty Permalinks.
     252                foreach ( $languages as $language ) {
     253                    // Add language codes to existing rewrite rules.
     254                    ${"new_key_$language"} = '(?:' . $language . ')/?' . ltrim($key, '^');
     255
     256                    // Add rules for each language.
     257                    $new_rules[ ${"new_key_$language"} ] = $val;
     258
     259                }
     260            }
     261            // Retain the original rule without the language code prefix.
     262            $new_rules[ $key ] = $val;
     263        }
     264
     265        return $new_rules;
     266    }
    252267}
  • fluentc-translation/trunk/src/models/class-fluentc-links-model.php

    r3159591 r3161147  
    77
    88namespace FluentC\Models;
     9
     10use FluentC\Utils\Language;
    911
    1012class FluentC_Links_Model {
     
    2931        );
    3032    }
     33
     34    function get_language_from_url( $field = 'slug' ) {
     35        $fluentc_language = new Language();
     36       
     37        $lang = $fluentc_language->fluentc_site_language();
     38   
     39        return $lang;
     40    }
    3141}
  • fluentc-translation/trunk/src/services/class-connect.php

    r3159591 r3161147  
    8383                }
    8484                // fetch available languages Environment ID.
    85                 $this->fluentc_cache->set( 'fluentc_language_list', $languages );
     85                $this->fluentc_cache->set_exp( 'fluentc_language_list', $languages, 43200 );
     86                do_action( 'fluentc_activation_setup' );
    8687            }
    8788        }
     
    111112
    112113            $this->fluentc_cache->set_exp( 'fluentc_display_language_list', $languages , 43200 );
     114            do_action( 'fluentc_activation_setup' );
    113115        }
    114116        return $languages;
     
    162164        // Re-index the array.
    163165        $languages = array_values( $languages );
    164         $this->heartbeat($widgetapikey);
     166       
    165167        // Return the requested fields or the full language objects.
    166168        return empty( $args['fields'] ) ? $languages : wp_list_pluck( $languages, $args['fields'] );
Note: See TracChangeset for help on using the changeset viewer.