Plugin Directory

Changeset 2899060


Ignore:
Timestamp:
04/14/2023 09:16:11 AM (3 years ago)
Author:
mdrejon
Message:

1.0.2

  • Tested WP 6.2 Compatibility
  • Updated: Appsero update
Location:
advance-faq-block/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • advance-faq-block/trunk/advance-faq-block.php

    r2886650 r2899060  
    55 * Requires at least: 6.1
    66 * Requires PHP:      7.0
    7  * Version:           1.0.1
     7 * Version:           1.0.2
    88 * Author:            Sydur Rahman
    99 * Author URI:        https://sydurrahman.com/
  • advance-faq-block/trunk/inc/appsero/src/Client.php

    r2886650 r2899060  
    11<?php
     2
    23namespace Appsero;
    34
     
    3233    /**
    3334     * The plugin/theme file path
     35     *
    3436     * @example .../wp-content/plugins/test-slug/test-slug.php
    3537     *
     
    4042    /**
    4143     * Main plugin file
     44     *
    4245     * @example test-slug/test-slug.php
    4346     *
     
    4851    /**
    4952     * Slug of the plugin
     53     *
    5054     * @example test-slug
    5155     *
     
    6973
    7074    /**
    71      * textdomain
     75     * Textdomain
    7276     *
    7377     * @var string
     
    96100    private $license;
    97101
    98     /**
     102    /**
    99103     * Initialize the class
    100104     *
    101      * @param string  $hash hash of the plugin
    102      * @param string  $name readable name of the plugin
    103      * @param string  $file main plugin file path
     105     * @param string $hash hash of the plugin
     106     * @param string $name readable name of the plugin
     107     * @param string $file main plugin file path
    104108     */
    105109    public function __construct( $hash, $name, $file ) {
     
    117121     */
    118122    public function insights() {
    119 
    120         if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
     123        if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) {
    121124            require_once __DIR__ . '/Insights.php';
    122125        }
     
    138141     */
    139142    public function updater() {
    140 
    141         if ( ! class_exists( __NAMESPACE__ . '\Updater') ) {
     143        if ( ! class_exists( __NAMESPACE__ . '\Updater' ) ) {
    142144            require_once __DIR__ . '/Updater.php';
    143145        }
     
    159161     */
    160162    public function license() {
    161 
    162         if ( ! class_exists( __NAMESPACE__ . '\License') ) {
     163        if ( ! class_exists( __NAMESPACE__ . '\License' ) ) {
    163164            require_once __DIR__ . '/License.php';
    164165        }
     
    191192     */
    192193    protected function set_basename_and_slug() {
    193 
    194194        if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {
    195195            $this->basename = plugin_basename( $this->file );
    196196
    197             list( $this->slug, $mainfile) = explode( '/', $this->basename );
     197            list( $this->slug, $mainfile ) = explode( '/', $this->basename );
    198198
    199199            require_once ABSPATH . 'wp-admin/includes/plugin.php';
     
    202202
    203203            $this->project_version = $plugin_data['Version'];
    204             $this->type = 'plugin';
     204            $this->type            = 'plugin';
    205205        } else {
    206206            $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
    207207
    208             list( $this->slug, $mainfile) = explode( '/', $this->basename );
     208            list( $this->slug, $mainfile ) = explode( '/', $this->basename );
    209209
    210210            $theme = wp_get_theme( $this->slug );
    211211
    212212            $this->project_version = $theme->version;
    213             $this->type = 'theme';
     213            $this->type            = 'theme';
    214214        }
    215215
     
    220220     * Send request to remote endpoint
    221221     *
    222      * @param  array  $params
    223      * @param  string $route
    224      *
    225      * @return array|WP_Error   Array of results including HTTP headers or WP_Error if the request failed.
     222     * @param array  $params
     223     * @param string $route
     224     *
     225     * @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed
    226226     */
    227227    public function send_request( $params, $route, $blocking = false ) {
    228228        $url = $this->endpoint() . $route;
    229229
    230         $headers = array(
     230        $headers = [
    231231            'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';',
    232232            'Accept'     => 'application/json',
     233        ];
     234
     235        $response = wp_remote_post(
     236            $url,
     237            [
     238                'method'      => 'POST',
     239                'timeout'     => 30,
     240                'redirection' => 5,
     241                'httpversion' => '1.0',
     242                'blocking'    => $blocking,
     243                'headers'     => $headers,
     244                'body'        => array_merge( $params, [ 'client' => $this->version ] ),
     245                'cookies'     => [],
     246            ]
    233247        );
    234248
    235         $response = wp_remote_post( $url, array(
    236             'method'      => 'POST',
    237             'timeout'     => 30,
    238             'redirection' => 5,
    239             'httpversion' => '1.0',
    240             'blocking'    => $blocking,
    241             'headers'     => $headers,
    242             'body'        => array_merge( $params, array( 'client' => $this->version ) ),
    243             'cookies'     => array()
    244         ) );
    245 
    246249        return $response;
    247250    }
     
    250253     * Check if the current server is localhost
    251254     *
    252      * @return boolean
     255     * @return bool
    253256     */
    254257    public function is_local_server() {
    255         $is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
     258        $is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ], true );
    256259
    257260        return apply_filters( 'appsero_is_local', $is_local );
     
    261264     * Translate function _e()
    262265     */
     266    // phpcs:ignore
    263267    public function _etrans( $text ) {
    264268        call_user_func( '_e', $text, $this->textdomain );
     
    268272     * Translate function __()
    269273     */
     274    // phpcs:ignore
    270275    public function __trans( $text ) {
    271276        return call_user_func( '__', $text, $this->textdomain );
  • advance-faq-block/trunk/inc/appsero/src/Insights.php

    r2886650 r2899060  
    11<?php
     2
    23namespace Appsero;
    3  
     4
    45/**
    56 * Appsero Insights
     
    2122     * Wheather to the notice or not
    2223     *
    23      * @var boolean
     24     * @var bool
    2425     */
    2526    protected $show_notice = true;
     
    3031     * @var array
    3132     */
    32     protected $extra_data = array();
     33    protected $extra_data = [];
    3334
    3435    /**
     
    4041
    4142    /**
    42      * @var boolean
     43     * @var bool
    4344     */
    4445    private $plugin_data = false;
    4546
    46 
    4747    /**
    4848     * Initialize the class
    4949     *
    50      * @param      $client
    5150     * @param null $name
    5251     * @param null $file
    5352     */
    5453    public function __construct( $client, $name = null, $file = null ) {
    55 
    5654        if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) {
    5755            $client = new Client( $client, $name, $file );
     
    9290     * @return \self
    9391     */
    94     public function add_extra( $data = array() ) {
     92    public function add_extra( $data = [] ) {
    9593        $this->extra_data = $data;
    9694
     
    10199     * Set custom notice text
    102100     *
    103      * @param  string $text
     101     * @param string $text
    104102     *
    105103     * @return \self
    106104     */
    107     public function notice($text='' ) {
     105    public function notice( $text = '' ) {
    108106        $this->notice = $text;
    109107
     
    117115     */
    118116    public function init() {
    119         if ( $this->client->type == 'plugin' ) {
     117        if ( $this->client->type === 'plugin' ) {
    120118            $this->init_plugin();
    121         } else if ( $this->client->type == 'theme' ) {
     119        } elseif ( $this->client->type === 'theme' ) {
    122120            $this->init_theme();
    123121        }
     
    132130        $this->init_common();
    133131
    134         add_action( 'switch_theme', array( $this, 'deactivation_cleanup' ) );
    135         add_action( 'switch_theme', array( $this, 'theme_deactivated' ), 12, 3 );
     132        add_action( 'switch_theme', [ $this, 'deactivation_cleanup' ] );
     133        add_action( 'switch_theme', [ $this, 'theme_deactivated' ], 12, 3 );
    136134    }
    137135
     
    144142        // plugin deactivate popup
    145143        if ( ! $this->is_local_server() ) {
    146             add_filter( 'plugin_action_links_' . $this->client->basename, array( $this, 'plugin_action_links' ) );
    147             add_action( 'admin_footer', array( $this, 'deactivate_scripts' ) );
     144            add_filter( 'plugin_action_links_' . $this->client->basename, [ $this, 'plugin_action_links' ] );
     145            add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] );
    148146        }
    149147
    150148        $this->init_common();
    151149
    152         register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) );
    153         register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) );
     150        register_activation_hook( $this->client->file, [ $this, 'activate_plugin' ] );
     151        register_deactivation_hook( $this->client->file, [ $this, 'deactivation_cleanup' ] );
    154152    }
    155153
     
    160158     */
    161159    protected function init_common() {
    162 
    163160        if ( $this->show_notice ) {
    164161            // tracking notice
    165             add_action( 'admin_notices', array( $this, 'admin_notice' ) );
    166         }
    167 
    168         add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
     162            add_action( 'admin_notices', [ $this, 'admin_notice' ] );
     163        }
     164
     165        add_action( 'admin_init', [ $this, 'handle_optin_optout' ] );
    169166
    170167        // uninstall reason
    171         add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $this, 'uninstall_reason_submission' ) );
     168        add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', [ $this, 'uninstall_reason_submission' ] );
    172169
    173170        // cron events
    174         add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) );
    175         add_action( $this->client->slug . '_tracker_send_event', array( $this, 'send_tracking_data' ) );
     171        add_filter( 'cron_schedules', [ $this, 'add_weekly_schedule' ] );
     172        add_action( $this->client->slug . '_tracker_send_event', [ $this, 'send_tracking_data' ] );
    176173        // add_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test
    177174    }
     
    180177     * Send tracking data to AppSero server
    181178     *
    182      * @param  boolean $override
     179     * @param bool $override
    183180     *
    184181     * @return void
     
    211208        $all_plugins = $this->get_all_plugins();
    212209
    213         $users = get_users( array(
    214             'role'    => 'administrator',
    215             'orderby' => 'ID',
    216             'order'   => 'ASC',
    217             'number'  => 1,
    218             'paged'   => 1,
    219         ) );
    220 
    221         $admin_user =  ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false;
    222         $first_name = $last_name = '';
     210        $users = get_users(
     211            [
     212                'role'    => 'administrator',
     213                'orderby' => 'ID',
     214                'order'   => 'ASC',
     215                'number'  => 1,
     216                'paged'   => 1,
     217            ]
     218        );
     219
     220        $admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false;
     221        $first_name = '';
     222        $last_name  = '';
    223223
    224224        if ( $admin_user ) {
     
    227227        }
    228228
    229         $data = array(
     229        $data = [
    230230            'url'              => esc_url( home_url() ),
    231231            'site'             => $this->get_site_name(),
     
    243243            'tracking_skipped' => false,
    244244            'is_local'         => $this->is_local_server(),
    245         );
     245        ];
    246246
    247247        // Add Plugins
    248         if ($this->plugin_data) {
    249            
    250             $plugins_data = array();
    251 
    252             foreach ($all_plugins['active_plugins'] as $slug => $plugin) {
    253                 $slug = strstr($slug, '/', true);
    254                 if (! $slug) {
     248        if ( $this->plugin_data ) {
     249            $plugins_data = [];
     250
     251            foreach ( $all_plugins['active_plugins'] as $slug => $plugin ) {
     252                $slug = strstr( $slug, '/', true );
     253
     254                if ( ! $slug ) {
    255255                    continue;
    256256                }
    257257
    258                 $plugins_data[ $slug ] = array(
    259                     'name' => isset($plugin['name']) ? $plugin['name'] : '',
    260                     'version' => isset($plugin['version']) ? $plugin['version'] : '',
    261                 );
    262             }
    263 
    264             if (array_key_exists($this->client->slug, $plugins_data)) {
    265                 unset($plugins_data[$this->client->slug]);
    266             }
    267            
     258                $plugins_data[ $slug ] = [
     259                    'name'      => isset( $plugin['name'] ) ? $plugin['name'] : '',
     260                    'version'   => isset( $plugin['version'] ) ? $plugin['version'] : '',
     261                ];
     262            }
     263
     264            if ( array_key_exists( $this->client->slug, $plugins_data ) ) {
     265                unset( $plugins_data[ $this->client->slug ] );
     266            }
     267
    268268            $data['plugins'] = $plugins_data;
    269269        }
    270270
    271         // Add metadata
    272         if ( $extra = $this->get_extra_data() ) {
     271        // Add Metadata
     272        $extra = $this->get_extra_data();
     273
     274        if ( $extra ) {
    273275            $data['extra'] = $extra;
    274276        }
     
    300302        }
    301303
    302         return array();
     304        return [];
    303305    }
    304306
     
    309311     */
    310312    protected function data_we_collect() {
    311         $data = array(
     313        $data = [
    312314            'Server environment details (php, mysql, server, WordPress versions)',
    313315            'Number of users in your site',
     
    316318            'Site name and URL',
    317319            'Your name and email address',
    318         );
    319 
    320         if ($this->plugin_data) {
    321             array_splice($data, 4, 0, ["active plugins' name"]);
     320        ];
     321
     322        if ( $this->plugin_data ) {
     323            array_splice( $data, 4, 0, [ "active plugins' name" ] );
    322324        }
    323325
     
    333335        $allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' );
    334336
    335         return $allow_tracking == 'yes';
     337        return $allow_tracking === 'yes';
    336338    }
    337339
     
    348350     * Check if the notice has been dismissed or enabled
    349351     *
    350      * @return boolean
     352     * @return bool
    351353     */
    352354    public function notice_dismissed() {
    353355        $hide_notice = get_option( $this->client->slug . '_tracking_notice', null );
    354356
    355         if ( 'hide' == $hide_notice ) {
     357        if ( 'hide' === $hide_notice ) {
    356358            return true;
    357359        }
     
    363365     * Check if the current server is localhost
    364366     *
    365      * @return boolean
     367     * @return bool
    366368     */
    367369    private function is_local_server() {
    368 
    369         $host       = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : 'localhost';
    370         $ip         = isset( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1';
     370        $host       = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : 'localhost';
     371        $ip         = isset( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) : '127.0.0.1';
    371372        $is_local   = false;
    372373
    373         if( in_array( $ip,array( '127.0.0.1', '::1' ) )
     374        if ( in_array( $ip, [ '127.0.0.1', '::1' ], true )
    374375            || ! strpos( $host, '.' )
    375             || in_array( strrchr( $host, '.' ), array( '.test', '.testing', '.local', '.localhost', '.localdomain' ) )
     376            || in_array( strrchr( $host, '.' ), [ '.test', '.testing', '.local', '.localhost', '.localdomain' ], true )
    376377        ) {
    377378            $is_local = true;
     
    387388     */
    388389    private function schedule_event() {
    389         $hook_name = $this->client->slug . '_tracker_send_event';
     390        $hook_name = wp_unslash( $this->client->slug . '_tracker_send_event' );
    390391
    391392        if ( ! wp_next_scheduled( $hook_name ) ) {
     
    409410     */
    410411    public function admin_notice() {
    411 
    412412        if ( $this->notice_dismissed() ) {
    413413            return;
     
    427427        }
    428428
    429         $optin_url  = add_query_arg( $this->client->slug . '_tracker_optin', 'true' );
    430         $optout_url = add_query_arg( $this->client->slug . '_tracker_optout', 'true' );
     429        $optin_url  = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optin', 'true' ), '_wpnonce' );
     430        $optout_url = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optout', 'true' ), '_wpnonce' );
    431431
    432432        if ( empty( $this->notice ) ) {
     
    436436        }
    437437
    438         $policy_url = 'https://' . 'appsero.com/privacy-policy/';
     438        $policy_url = 'https://appsero.com/privacy-policy/';
    439439
    440440        $notice .= ' (<a class="' . $this->client->slug . '-insights-data-we-collect" href="#">' . $this->client->__trans( 'what we collect' ) . '</a>)';
     
    443443
    444444        echo '<div class="updated"><p>';
    445             echo $notice;
    446             echo '</p><p class="submit">';
    447             echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-primary button-large">' . $this->client->__trans( 'Allow' ) . '</a>';
    448             echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary button-large">' . $this->client->__trans( 'No thanks' ) . '</a>';
     445        echo $notice;
     446        echo '</p><p class="submit">';
     447        echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-primary button-large">' . $this->client->__trans( 'Allow' ) . '</a>';
     448        echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary button-large">' . $this->client->__trans( 'No thanks' ) . '</a>';
    449449        echo '</p></div>';
    450450
     
    458458
    459459    /**
    460      * handle the optin/optout
     460     * Handle the optin/optout
    461461     *
    462462     * @return void
    463463     */
    464464    public function handle_optin_optout() {
    465 
    466         if ( isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && $_GET[ $this->client->slug . '_tracker_optin' ] == 'true' ) {
     465        if ( ! isset( $_GET['_wpnonce'] ) ) {
     466            return;
     467        }
     468
     469        if ( ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), '_wpnonce' ) ) {
     470            return;
     471        }
     472
     473        if ( isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && $_GET[ $this->client->slug . '_tracker_optin' ] === 'true' ) {
    467474            $this->optin();
    468475
    469             wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optin' ) );
     476            wp_safe_redirect( remove_query_arg( $this->client->slug . '_tracker_optin' ) );
    470477            exit;
    471478        }
    472479
    473         if ( isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && $_GET[ $this->client->slug . '_tracker_optout' ] == 'true' ) {
     480        if ( isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && $_GET[ $this->client->slug . '_tracker_optout' ] === 'true' ) {
    474481            $this->optout();
    475482
    476             wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optout' ) );
     483            wp_safe_redirect( remove_query_arg( $this->client->slug . '_tracker_optout' ) );
    477484            exit;
    478485        }
     
    492499        $this->send_tracking_data();
    493500
    494         /**
     501        /*
    495502         * Fires when the user has opted in tracking.
    496503         */
     
    511518        $this->clear_schedule_event();
    512519
    513         /**
     520        /*
    514521         * Fires when the user has opted out tracking.
    515522         */
     
    520527     * Get the number of post counts
    521528     *
    522      * @param  string $post_type
    523      *
    524      * @return integer
     529     * @param string $post_type
     530     *
     531     * @return int
    525532     */
    526533    public function get_post_count( $post_type ) {
    527534        global $wpdb;
    528535
    529         return (int) $wpdb->get_var( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '$post_type' and post_status = 'publish'");
     536        return (int) $wpdb->get_var(
     537            $wpdb->prepare(
     538                "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = %s",
     539                [ $post_type, 'publish' ]
     540            )
     541        );
    530542    }
    531543
     
    538550        global $wpdb;
    539551
    540         $server_data = array();
     552        $server_data = [];
    541553
    542554        if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
     555            // phpcs:ignore
    543556            $server_data['software'] = $_SERVER['SERVER_SOFTWARE'];
    544557        }
     
    548561        }
    549562
    550         $server_data['mysql_version']        = $wpdb->db_version();
     563        $server_data['mysql_version'] = $wpdb->db_version();
    551564
    552565        $server_data['php_max_upload_size']  = size_format( wp_max_upload_size() );
     
    565578     */
    566579    private function get_wp_info() {
    567         $wp_data = array();
     580        $wp_data = [];
    568581
    569582        $wp_data['memory_limit'] = WP_MEMORY_LIMIT;
    570         $wp_data['debug_mode']   = ( defined('WP_DEBUG') && WP_DEBUG ) ? 'Yes' : 'No';
     583        $wp_data['debug_mode']   = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
    571584        $wp_data['locale']       = get_locale();
    572585        $wp_data['version']      = get_bloginfo( 'version' );
     
    596609
    597610        $plugins             = get_plugins();
    598         $active_plugins_keys = get_option( 'active_plugins', array() );
    599         $active_plugins      = array();
     611        $active_plugins_keys = get_option( 'active_plugins', [] );
     612        $active_plugins      = [];
    600613
    601614        foreach ( $plugins as $k => $v ) {
    602615            // Take care of formatting the data how we want it.
    603             $formatted = array();
    604             $formatted['name'] = strip_tags( $v['Name'] );
     616            $formatted         = [];
     617            $formatted['name'] = wp_strip_all_tags( $v['Name'] );
    605618
    606619            if ( isset( $v['Version'] ) ) {
    607                 $formatted['version'] = strip_tags( $v['Version'] );
     620                $formatted['version'] = wp_strip_all_tags( $v['Version'] );
    608621            }
    609622
    610623            if ( isset( $v['Author'] ) ) {
    611                 $formatted['author'] = strip_tags( $v['Author'] );
     624                $formatted['author'] = wp_strip_all_tags( $v['Author'] );
    612625            }
    613626
    614627            if ( isset( $v['Network'] ) ) {
    615                 $formatted['network'] = strip_tags( $v['Network'] );
     628                $formatted['network'] = wp_strip_all_tags( $v['Network'] );
    616629            }
    617630
    618631            if ( isset( $v['PluginURI'] ) ) {
    619                 $formatted['plugin_uri'] = strip_tags( $v['PluginURI'] );
    620             }
    621 
    622             if ( in_array( $k, $active_plugins_keys ) ) {
     632                $formatted['plugin_uri'] = wp_strip_all_tags( $v['PluginURI'] );
     633            }
     634
     635            if ( in_array( $k, $active_plugins_keys, true ) ) {
    623636                // Remove active plugins from list so we can show active and inactive separately
    624                 unset( $plugins[$k] );
    625                 $active_plugins[$k] = $formatted;
     637                unset( $plugins[ $k ] );
     638                $active_plugins[ $k ] = $formatted;
    626639            } else {
    627                 $plugins[$k] = $formatted;
    628             }
    629         }
    630 
    631         return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
     640                $plugins[ $k ] = $formatted;
     641            }
     642        }
     643
     644        return [
     645            'active_plugins'    => $active_plugins,
     646            'inactive_plugins'  => $plugins,
     647        ];
    632648    }
    633649
     
    638654     */
    639655    public function get_user_counts() {
    640         $user_count          = array();
     656        $user_count          = [];
    641657        $user_count_data     = count_users();
    642658        $user_count['total'] = $user_count_data['total_users'];
     
    657673     * Add weekly cron schedule
    658674     *
    659      * @param array  $schedules
     675     * @param array $schedules
    660676     *
    661677     * @return array
    662678     */
    663679    public function add_weekly_schedule( $schedules ) {
    664 
    665         $schedules['weekly'] = array(
     680        $schedules['weekly'] = [
    666681            'interval' => DAY_IN_SECONDS * 7,
    667682            'display'  => 'Once Weekly',
    668         );
     683        ];
    669684
    670685        return $schedules;
     
    686701        // re-schedule and delete the last sent time so we could force send again
    687702        $hook_name = $this->client->slug . '_tracker_send_event';
     703
    688704        if ( ! wp_next_scheduled( $hook_name ) ) {
    689705            wp_schedule_event( time(), 'weekly', $hook_name );
     
    703719        $this->clear_schedule_event();
    704720
    705         if ( 'theme' == $this->client->type ) {
     721        if ( 'theme' === $this->client->type ) {
    706722            delete_option( $this->client->slug . '_tracking_last_send' );
    707723            delete_option( $this->client->slug . '_allow_tracking' );
     
    714730     * Hook into action links and modify the deactivate link
    715731     *
    716      * @param  array $links
     732     * @param array $links
    717733     *
    718734     * @return array
    719735     */
    720736    public function plugin_action_links( $links ) {
    721 
    722737        if ( array_key_exists( 'deactivate', $links ) ) {
    723738            $links['deactivate'] = str_replace( '<a', '<a class="' . $this->client->slug . '-deactivate-link"', $links['deactivate'] );
     
    733748     */
    734749    private function get_uninstall_reasons() {
    735         $reasons = array(
    736             array(
    737                 'id'          => 'could-not-understand',
    738                 'text'        => $this->client->__trans( "Couldn't understand" ),
    739                 'placeholder' => $this->client->__trans( 'Would you like us to assist you?' ),
    740                 'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 10.6 23 9.6 22.9 8.8 22.7L8.8 22.6C9.3 22.5 9.7 22.3 10 21.9 10.3 21.6 10.4 21.3 10.4 20.9 10.8 21 11.1 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2 6.3 2 2 6.3 2 11.5 2 13 2.3 14.3 2.9 15.6 2.7 16 2.4 16.3 2.2 16.8L2.1 17.1 2.1 17.3C2 17.5 2 17.7 2 18 0.7 16.1 0 13.9 0 11.5 0 5.1 5.1 0 11.5 0ZM6 13.6C6 13.7 6.1 13.8 6.1 13.9 6.3 14.5 6.2 15.7 6.1 16.4 6.1 16.6 6 16.9 6 17.1 6 17.1 6.1 17.1 6.1 17.1 7.1 16.9 8.2 16 9.3 15.5 9.8 15.2 10.4 15 10.9 15 11.2 15 11.4 15 11.6 15.2 11.9 15.4 12.1 16 11.6 16.4 11.5 16.5 11.3 16.6 11.1 16.7 10.5 17 9.9 17.4 9.3 17.7 9 17.9 9 18.1 9.1 18.5 9.2 18.9 9.3 19.4 9.3 19.8 9.4 20.3 9.3 20.8 9 21.2 8.8 21.5 8.5 21.6 8.1 21.7 7.9 21.8 7.6 21.9 7.3 21.9L6.5 22C6.3 22 6 21.9 5.8 21.9 5 21.8 4.4 21.5 3.9 20.9 3.3 20.4 3.1 19.6 3 18.8L3 18.5C3 18.2 3 17.9 3.1 17.7L3.1 17.6C3.2 17.1 3.5 16.7 3.7 16.3 4 15.9 4.2 15.4 4.3 15 4.4 14.6 4.4 14.5 4.6 14.2 4.6 13.9 4.7 13.7 4.9 13.6 5.2 13.2 5.7 13.2 6 13.6ZM11.7 11.2C13.1 11.2 14.3 11.7 15.2 12.9 15.3 13 15.4 13.1 15.4 13.2 15.4 13.4 15.3 13.8 15.2 13.8 15 13.9 14.9 13.8 14.8 13.7 14.6 13.5 14.4 13.2 14.1 13.1 13.5 12.6 12.8 12.3 12 12.2 10.7 12.1 9.5 12.3 8.4 12.8 8.3 12.8 8.2 12.8 8.1 12.8 7.9 12.8 7.8 12.4 7.8 12.2 7.7 12.1 7.8 11.9 8 11.8 8.4 11.7 8.8 11.5 9.2 11.4 10 11.2 10.9 11.1 11.7 11.2ZM16.3 5.9C17.3 5.9 18 6.6 18 7.6 18 8.5 17.3 9.3 16.3 9.3 15.4 9.3 14.7 8.5 14.7 7.6 14.7 6.6 15.4 5.9 16.3 5.9ZM8.3 5C9.2 5 9.9 5.8 9.9 6.7 9.9 7.7 9.2 8.4 8.2 8.4 7.3 8.4 6.6 7.7 6.6 6.7 6.6 5.8 7.3 5 8.3 5Z"/></g></g></svg>'
    741             ),
    742             array(
    743                 'id'          => 'found-better-plugin',
    744                 'text'        => $this->client->__trans( 'Found a better plugin' ),
    745                 'placeholder' => $this->client->__trans( 'Which plugin?' ),
     750        $reasons = [
     751            [
     752                'id'          => 'could-not-understand',
     753                'text'        => $this->client->__trans( "Couldn't understand" ),
     754                'placeholder' => $this->client->__trans( 'Would you like us to assist you?' ),
     755                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 10.6 23 9.6 22.9 8.8 22.7L8.8 22.6C9.3 22.5 9.7 22.3 10 21.9 10.3 21.6 10.4 21.3 10.4 20.9 10.8 21 11.1 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2 6.3 2 2 6.3 2 11.5 2 13 2.3 14.3 2.9 15.6 2.7 16 2.4 16.3 2.2 16.8L2.1 17.1 2.1 17.3C2 17.5 2 17.7 2 18 0.7 16.1 0 13.9 0 11.5 0 5.1 5.1 0 11.5 0ZM6 13.6C6 13.7 6.1 13.8 6.1 13.9 6.3 14.5 6.2 15.7 6.1 16.4 6.1 16.6 6 16.9 6 17.1 6 17.1 6.1 17.1 6.1 17.1 7.1 16.9 8.2 16 9.3 15.5 9.8 15.2 10.4 15 10.9 15 11.2 15 11.4 15 11.6 15.2 11.9 15.4 12.1 16 11.6 16.4 11.5 16.5 11.3 16.6 11.1 16.7 10.5 17 9.9 17.4 9.3 17.7 9 17.9 9 18.1 9.1 18.5 9.2 18.9 9.3 19.4 9.3 19.8 9.4 20.3 9.3 20.8 9 21.2 8.8 21.5 8.5 21.6 8.1 21.7 7.9 21.8 7.6 21.9 7.3 21.9L6.5 22C6.3 22 6 21.9 5.8 21.9 5 21.8 4.4 21.5 3.9 20.9 3.3 20.4 3.1 19.6 3 18.8L3 18.5C3 18.2 3 17.9 3.1 17.7L3.1 17.6C3.2 17.1 3.5 16.7 3.7 16.3 4 15.9 4.2 15.4 4.3 15 4.4 14.6 4.4 14.5 4.6 14.2 4.6 13.9 4.7 13.7 4.9 13.6 5.2 13.2 5.7 13.2 6 13.6ZM11.7 11.2C13.1 11.2 14.3 11.7 15.2 12.9 15.3 13 15.4 13.1 15.4 13.2 15.4 13.4 15.3 13.8 15.2 13.8 15 13.9 14.9 13.8 14.8 13.7 14.6 13.5 14.4 13.2 14.1 13.1 13.5 12.6 12.8 12.3 12 12.2 10.7 12.1 9.5 12.3 8.4 12.8 8.3 12.8 8.2 12.8 8.1 12.8 7.9 12.8 7.8 12.4 7.8 12.2 7.7 12.1 7.8 11.9 8 11.8 8.4 11.7 8.8 11.5 9.2 11.4 10 11.2 10.9 11.1 11.7 11.2ZM16.3 5.9C17.3 5.9 18 6.6 18 7.6 18 8.5 17.3 9.3 16.3 9.3 15.4 9.3 14.7 8.5 14.7 7.6 14.7 6.6 15.4 5.9 16.3 5.9ZM8.3 5C9.2 5 9.9 5.8 9.9 6.7 9.9 7.7 9.2 8.4 8.2 8.4 7.3 8.4 6.6 7.7 6.6 6.7 6.6 5.8 7.3 5 8.3 5Z"/></g></g></svg>',
     756            ],
     757            [
     758                'id'          => 'found-better-plugin',
     759                'text'        => $this->client->__trans( 'Found a better plugin' ),
     760                'placeholder' => $this->client->__trans( 'Which plugin?' ),
    746761                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M17.1 14L22.4 19.3C23.2 20.2 23.2 21.5 22.4 22.4 21.5 23.2 20.2 23.2 19.3 22.4L19.3 22.4 14 17.1C15.3 16.3 16.3 15.3 17.1 14L17.1 14ZM8.6 0C13.4 0 17.3 3.9 17.3 8.6 17.3 13.4 13.4 17.2 8.6 17.2 3.9 17.2 0 13.4 0 8.6 0 3.9 3.9 0 8.6 0ZM8.6 2.2C5.1 2.2 2.2 5.1 2.2 8.6 2.2 12.2 5.1 15.1 8.6 15.1 12.2 15.1 15.1 12.2 15.1 8.6 15.1 5.1 12.2 2.2 8.6 2.2ZM8.6 3.6L8.6 5C6.6 5 5 6.6 5 8.6L5 8.6 3.6 8.6C3.6 5.9 5.9 3.6 8.6 3.6L8.6 3.6Z"/></g></g></svg>',
    747             ),
    748             array(
    749                 'id'          => 'not-have-that-feature',
    750                 'text'        => $this->client->__trans( "Missing a specific feature" ),
    751                 'placeholder' => $this->client->__trans( 'Could you tell us more about that feature?' ),
     762            ],
     763            [
     764                'id'          => 'not-have-that-feature',
     765                'text'        => $this->client->__trans( 'Missing a specific feature' ),
     766                'placeholder' => $this->client->__trans( 'Could you tell us more about that feature?' ),
    752767                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M19.4 0C19.7 0.6 19.8 1.3 19.8 2 19.8 3.2 19.4 4.4 18.5 5.3 17.6 6.2 16.5 6.7 15.2 6.7 15.2 6.7 15.2 6.7 15.2 6.7 14 6.7 12.9 6.2 12 5.3 11.2 4.4 10.7 3.3 10.7 2 10.7 1.3 10.8 0.6 11.1 0L7.6 0 7 0 6.5 0 6.5 5.7C6.3 5.6 5.9 5.3 5.6 5.1 5 4.6 4.3 4.3 3.5 4.3 3.5 4.3 3.5 4.3 3.4 4.3 1.6 4.4 0 5.9 0 7.9 0 8.6 0.2 9.2 0.5 9.7 1.1 10.8 2.2 11.5 3.5 11.5 4.3 11.5 5 11.2 5.6 10.8 6 10.5 6.3 10.3 6.5 10.2L6.5 10.2 6.5 17 6.5 17 7 17 7.6 17 22.5 17C23.3 17 24 16.3 24 15.5L24 0 19.4 0Z"/></g></g></svg>',
    753             ),
    754             array(
    755                 'id'          => 'is-not-working',
    756                 'text'        => $this->client->__trans( 'Not working' ),
    757                 'placeholder' => $this->client->__trans( 'Could you tell us a bit more whats not working?' ),
     768            ],
     769            [
     770                'id'          => 'is-not-working',
     771                'text'        => $this->client->__trans( 'Not working' ),
     772                'placeholder' => $this->client->__trans( 'Could you tell us a bit more whats not working?' ),
    758773                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.8 14.4C11.2 14.4 10.7 14.8 10.7 15.4 10.7 16 11.2 16.4 11.8 16.4 12.4 16.4 12.8 16 12.8 15.4 12.8 14.8 12.4 14.4 11.8 14.4ZM12 7C10.1 7 9.1 8.1 9 9.6L10.5 9.6C10.5 8.8 11.1 8.3 11.9 8.3 12.7 8.3 13.2 8.8 13.2 9.5 13.2 10.1 13 10.4 12.2 10.9 11.3 11.4 10.9 12 11 12.9L11 13.4 12.5 13.4 12.5 13C12.5 12.4 12.7 12.1 13.5 11.6 14.4 11.1 14.9 10.4 14.9 9.4 14.9 8 13.7 7 12 7Z"/></g></g></svg>',
    759             ),
    760             array(
    761                 'id'          => 'looking-for-other',
    762                 'text'        => $this->client->__trans( "Not what I was looking" ),
    763                 'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ),
     774            ],
     775            [
     776                'id'          => 'looking-for-other',
     777                'text'        => $this->client->__trans( 'Not what I was looking' ),
     778                'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ),
    764779                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M23.5 9C23.5 9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.4 8.6 23.2 8.3 23 8 22.2 6.5 20.6 3.7 19.8 2.6 18.8 1.3 17.7 0 16.1 0 15.7 0 15.3 0.1 14.9 0.2 13.8 0.6 12.6 1.2 12.3 2.7L11.7 2.7C11.4 1.2 10.2 0.6 9.1 0.2 8.7 0.1 8.3 0 7.9 0 6.3 0 5.2 1.3 4.2 2.6 3.4 3.7 1.8 6.5 1 8 0.8 8.3 0.6 8.6 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 9 0.5 9 0.2 9.7 0 10.5 0 11.3 0 14.4 2.5 17 5.5 17 7.3 17 8.8 16.1 9.8 14.8L14.2 14.8C15.2 16.1 16.7 17 18.5 17 21.5 17 24 14.4 24 11.3 24 10.5 23.8 9.7 23.5 9ZM5.5 15C3.6 15 2 13.2 2 11 2 8.8 3.6 7 5.5 7 7.4 7 9 8.8 9 11 9 13.2 7.4 15 5.5 15ZM18.5 15C16.6 15 15 13.2 15 11 15 8.8 16.6 7 18.5 7 20.4 7 22 8.8 22 11 22 13.2 20.4 15 18.5 15Z"/></g></g></svg>',
    765             ),
    766             array(
    767                 'id'          => 'did-not-work-as-expected',
    768                 'text'        => $this->client->__trans( "Didn't work as expected" ),
    769                 'placeholder' => $this->client->__trans( 'What did you expect?' ),
     780            ],
     781            [
     782                'id'          => 'did-not-work-as-expected',
     783                'text'        => $this->client->__trans( "Didn't work as expected" ),
     784                'placeholder' => $this->client->__trans( 'What did you expect?' ),
    770785                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.5 2C6.3 2 2 6.3 2 11.5 2 16.7 6.3 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2ZM12.5 12.9L12.7 5 10.2 5 10.5 12.9 12.5 12.9ZM11.5 17.4C12.4 17.4 13 16.8 13 15.9 13 15 12.4 14.4 11.5 14.4 10.6 14.4 10 15 10 15.9 10 16.8 10.6 17.4 11.5 17.4Z"/></g></g></svg>',
    771             ),
    772             array(
    773                 'id'          => 'other',
    774                 'text'        => $this->client->__trans( 'Others' ),
    775                 'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ),
     786            ],
     787            [
     788                'id'          => 'other',
     789                'text'        => $this->client->__trans( 'Others' ),
     790                'placeholder' => $this->client->__trans( 'Could you tell us a bit more?' ),
    776791                'icon'        => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="23" viewBox="0 0 24 6"><g fill="none"><g fill="#3B86FF"><path d="M3 0C4.7 0 6 1.3 6 3 6 4.7 4.7 6 3 6 1.3 6 0 4.7 0 3 0 1.3 1.3 0 3 0ZM12 0C13.7 0 15 1.3 15 3 15 4.7 13.7 6 12 6 10.3 6 9 4.7 9 3 9 1.3 10.3 0 12 0ZM21 0C22.7 0 24 1.3 24 3 24 4.7 22.7 6 21 6 19.3 6 18 4.7 18 3 18 1.3 19.3 0 21 0Z"/></g></g></svg>',
    777             ),
    778         );
     792            ],
     793        ];
    779794
    780795        return $reasons;
     
    787802     */
    788803    public function uninstall_reason_submission() {
     804        if ( ! isset( $_POST['nonce'] ) ) {
     805            return;
     806        }
    789807
    790808        if ( ! isset( $_POST['reason_id'] ) ) {
     
    792810        }
    793811
    794         if ( ! wp_verify_nonce( sanitize_text_field($_POST['nonce']), 'appsero-security-nonce' ) ) {
     812        if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'appsero-security-nonce' ) ) {
    795813            wp_send_json_error( 'Nonce verification failed' );
    796814        }
     
    800818        }
    801819
    802         $data                = $this->get_tracking_data();
    803         $data['reason_id']   = sanitize_text_field( $_POST['reason_id'] );
    804         $data['reason_info'] = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( sanitize_text_field($_REQUEST['reason_info']) ) ) : '';
     820        $data['reason_id']   = sanitize_text_field( wp_unslash( $_POST['reason_id'] ) );
     821        $data['reason_info'] = isset( $_REQUEST['reason_info'] ) ? trim( sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) ) : '';
    805822
    806823        $this->client->send_request( $data, 'deactivate' );
    807824
    808         /**
    809          * Fire after the plugin _uninstall_reason_submitted 
     825        /*
     826         * Fire after the plugin _uninstall_reason_submitted
    810827         */
    811828        do_action( $this->client->slug . '_uninstall_reason_submitted', $data );
     
    822839        global $pagenow;
    823840
    824         if ( 'plugins.php' != $pagenow ) {
     841        if ( 'plugins.php' !== $pagenow ) {
    825842            return;
    826843        }
    827844
    828845        $this->deactivation_modal_styles();
    829         $reasons = $this->get_uninstall_reasons();
    830         $custom_reasons = apply_filters( 'appsero_custom_deactivation_reasons', array() );
     846        $reasons        = $this->get_uninstall_reasons();
     847        $custom_reasons = apply_filters( 'appsero_custom_deactivation_reasons', [], $this->client );
    831848        ?>
    832849
     
    849866                        <?php } ?>
    850867                    </ul>
    851                     <?php if ( $custom_reasons && is_array( $custom_reasons ) ) : ?>
     868                    <?php if ( $custom_reasons && is_array( $custom_reasons ) ) { ?>
    852869                    <ul class="wd-de-reasons wd-de-others-reasons">
    853870                        <?php foreach ( $custom_reasons as $reason ) { ?>
     
    861878                        <?php } ?>
    862879                    </ul>
    863                     <?php endif; ?>
     880                    <?php } ?>
    864881                    <div class="wd-dr-modal-reason-input"><textarea></textarea></div>
    865882                    <p class="wd-dr-modal-reasons-bottom">
    866                        <?php
    867                        echo sprintf(
    868                            $this->client->__trans( 'We share your data with <a href="%1$s" target="_blank">Appsero</a> to troubleshoot problems &amp; make product improvements. <a href="%2$s" target="_blank">Learn more</a> about how Appsero handles your data.'),
    869                            esc_url( 'https://appsero.com/' ),
    870                            esc_url( 'https://appsero.com/privacy-policy' )
    871                        );
    872                        ?>
     883                        <?php
     884                        echo sprintf(
     885                            $this->client->__trans( 'We share your data with <a href="%1$s" target="_blank">Appsero</a> to troubleshoot problems &amp; make product improvements. <a href="%2$s" target="_blank">Learn more</a> about how Appsero handles your data.' ),
     886                            esc_url( 'https://appsero.com/' ),
     887                            esc_url( 'https://appsero.com/privacy-policy' )
     888                        );
     889                        ?>
    873890                    </p>
    874891                </div>
    875892
    876893                <div class="wd-dr-modal-footer">
    877                     <a href="#" class="dont-bother-me wd-dr-button-secondary"><?php $this->client->_etrans( "Skip & Deactivate" ); ?></a>
     894                    <a href="#" class="dont-bother-me wd-dr-button-secondary"><?php $this->client->_etrans( 'Skip & Deactivate' ); ?></a>
    878895                    <button class="wd-dr-button-secondary wd-dr-cancel-modal"><?php $this->client->_etrans( 'Cancel' ); ?></button>
    879896                    <button class="wd-dr-submit-modal"><?php $this->client->_etrans( 'Submit & Deactivate' ); ?></button>
     
    970987    /**
    971988     * Run after theme deactivated
    972      * @param  string $new_name
    973      * @param  object $new_theme
    974      * @param  object $old_theme
     989     *
     990     * @param string $new_name
     991     * @param object $new_theme
     992     * @param object $old_theme
     993     *
    975994     * @return void
    976995     */
    977996    public function theme_deactivated( $new_name, $new_theme, $old_theme ) {
    978997        // Make sure this is appsero theme
    979         if ( $old_theme->get_template() == $this->client->slug ) {
     998        if ( $old_theme->get_template() === $this->client->slug ) {
    980999            $this->client->send_request( $this->get_tracking_data(), 'deactivate' );
    9811000        }
     
    10251044        $skipped = get_option( $this->client->slug . '_tracking_skipped' );
    10261045
    1027         $data = array(
     1046        $data = [
    10281047            'hash'               => $this->client->hash,
    10291048            'previously_skipped' => false,
    1030         );
     1049        ];
    10311050
    10321051        if ( $skipped === 'yes' ) {
     
    12001219        <?php
    12011220    }
    1202 
    12031221}
  • advance-faq-block/trunk/inc/appsero/src/License.php

    r2886650 r2899060  
    22
    33namespace Appsero;
    4  
     4
    55/**
    66 * Appsero License Checker
     
    88 * This class will check, active and deactive license
    99 */
    10 class License
    11 {
     10class License {
    1211
    1312    /**
     
    6564     * @param Appsero\Client
    6665     */
    67     public function __construct(Client $client)
    68     {
     66    public function __construct( Client $client ) {
    6967        $this->client = $client;
    7068
    71         $this->option_key = 'appsero_' . md5($this->client->slug) . '_manage_license';
     69        $this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license';
    7270
    7371        $this->schedule_hook = $this->client->slug . '_license_check_event';
    7472
    7573        // Creating WP Ajax Endpoint to refresh license remotely
    76         add_action("wp_ajax_appsero_refresh_license_" . $this->client->hash, array($this, 'refresh_license_api'));
     74        add_action( 'wp_ajax_appsero_refresh_license_' . $this->client->hash, [ $this, 'refresh_license_api' ] );
    7775
    7876        // Run hook to check license status daily
    79         add_action($this->schedule_hook, array($this, 'check_license_status'));
     77        add_action( $this->schedule_hook, [ $this, 'check_license_status' ] );
    8078
    8179        // Active/Deactive corn schedule
     
    9492     * @return License
    9593     */
    96     public function set_option_key($key)
    97     {
     94    public function set_option_key( $key ) {
    9895        $this->option_key = $key;
    9996
     
    108105     * @return string|null
    109106     */
    110     public function get_license()
    111     {
    112         return get_option($this->option_key, null);
     107    public function get_license() {
     108        return get_option( $this->option_key, null );
    113109    }
    114110
     
    118114     * @return bool
    119115     */
    120     public function check($license_key)
    121     {
    122         $route    = 'public/license/' . $this->client->hash . '/check';
    123 
    124         return $this->send_request($license_key, $route);
     116    public function check( $license_key ) {
     117        $route = 'public/license/' . $this->client->hash . '/check';
     118
     119        return $this->send_request( $license_key, $route );
    125120    }
    126121
     
    130125     * @return bool
    131126     */
    132     public function activate($license_key)
    133     {
    134         $route    = 'public/license/' . $this->client->hash . '/activate';
    135 
    136         return $this->send_request($license_key, $route);
     127    public function activate( $license_key ) {
     128        $route = 'public/license/' . $this->client->hash . '/activate';
     129
     130        return $this->send_request( $license_key, $route );
    137131    }
    138132
     
    142136     * @return bool
    143137     */
    144     public function deactivate($license_key)
    145     {
    146         $route    = 'public/license/' . $this->client->hash . '/deactivate';
    147 
    148         return $this->send_request($license_key, $route);
     138    public function deactivate( $license_key ) {
     139        $route = 'public/license/' . $this->client->hash . '/deactivate';
     140
     141        return $this->send_request( $license_key, $route );
    149142    }
    150143
     
    152145     * Send common request
    153146     *
    154      * @param $license_key
    155      * @param $route
    156      *
    157147     * @return array
    158148     */
    159     protected function send_request($license_key, $route)
    160     {
    161         $params = array(
     149    protected function send_request( $license_key, $route ) {
     150        $params = [
    162151            'license_key' => $license_key,
    163             'url'         => esc_url(home_url()),
     152            'url'         => esc_url( home_url() ),
    164153            'is_local'    => $this->client->is_local_server(),
    165         );
    166 
    167         $response = $this->client->send_request($params, $route, true);
    168 
    169         if (is_wp_error($response)) {
    170             return array(
     154        ];
     155
     156        $response = $this->client->send_request( $params, $route, true );
     157
     158        if ( is_wp_error( $response ) ) {
     159            return [
    171160                'success' => false,
    172                 'error'   => $response->get_error_message()
    173             );
    174         }
    175 
    176         $response = json_decode(wp_remote_retrieve_body($response), true);
    177 
    178         if (empty($response) || isset($response['exception'])) {
    179             return array(
     161                'error'   => $response->get_error_message(),
     162            ];
     163        }
     164
     165        $response = json_decode( wp_remote_retrieve_body( $response ), true );
     166
     167        if ( empty( $response ) || isset( $response['exception'] ) ) {
     168            return [
    180169                'success' => false,
    181                 'error'   => $this->client->__trans('Unknown error occurred, Please try again.'),
    182             );
    183         }
    184 
    185         if (isset($response['errors']) && isset($response['errors']['license_key'])) {
    186             $response = array(
     170                'error'   => $this->client->__trans( 'Unknown error occurred, Please try again.' ),
     171            ];
     172        }
     173
     174        if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) {
     175            $response = [
    187176                'success' => false,
    188                 'error'   => $response['errors']['license_key'][0]
    189             );
     177                'error'   => $response['errors']['license_key'][0],
     178            ];
    190179        }
    191180
     
    196185     * License Refresh Endpoint
    197186     */
    198     public function refresh_license_api()
    199     {
     187    public function refresh_license_api() {
    200188        $this->check_license_status();
    201189
    202190        return wp_send_json(
    203             array(
    204                 'message' => 'License refreshed successfully.'
    205             ),
     191            [
     192                'message' => 'License refreshed successfully.',
     193            ],
    206194            200
    207195        );
     
    215203     * @return void
    216204     */
    217     public function add_settings_page($args = array())
    218     {
    219         $defaults = array(
     205    public function add_settings_page( $args = [] ) {
     206        $defaults = [
    220207            'type'        => 'menu', // Can be: menu, options, submenu
    221208            'page_title'  => 'Manage License',
     
    226213            'position'    => null,
    227214            'parent_slug' => '',
    228         );
    229 
    230         $this->menu_args = wp_parse_args($args, $defaults);
    231 
    232         add_action('admin_menu', array($this, 'admin_menu'), 99);
     215        ];
     216
     217        $this->menu_args = wp_parse_args( $args, $defaults );
     218
     219        add_action( 'admin_menu', [ $this, 'admin_menu' ], 99 );
    233220    }
    234221
     
    238225     * @return void
    239226     */
    240     public function admin_menu()
    241     {
    242         switch ($this->menu_args['type']) {
     227    public function admin_menu() {
     228        switch ( $this->menu_args['type'] ) {
    243229            case 'menu':
    244230                $this->create_menu_page();
     
    258244     * License menu output
    259245     */
    260     public function menu_output()
    261     {
    262         if (isset($_POST['submit'])) {
    263             $this->license_form_submit($_POST);
    264         }
     246    public function menu_output() {
     247        // process form data is submitted
     248        $this->license_form_submit();
    265249
    266250        $license = $this->get_license();
    267         $action  = ($license && isset($license['status']) && 'activate' == sanitize_text_field($license['status'])) ? 'deactive' : 'active';
     251        $action  = ( $license && isset( $license['status'] ) && 'activate' === $license['status'] ) ? 'deactive' : 'active';
    268252        $this->licenses_style();
    269 ?>
     253        ?>
    270254
    271255        <div class="wrap appsero-license-settings-wrapper">
     
    273257
    274258            <?php
    275             $this->show_license_page_notices();
    276             do_action('before_appsero_license_section');
     259                $this->show_license_page_notices();
     260                do_action( 'before_appsero_license_section' );
    277261            ?>
    278262
    279263            <div class="appsero-license-settings appsero-license-section">
    280                 <?php $this->show_license_page_card_header($license); ?>
     264                <?php $this->show_license_page_card_header( $license ); ?>
    281265
    282266                <div class="appsero-license-details">
    283267                    <p>
    284                         <?php printf($this->client->__trans('Activate <strong>%s</strong> by your license key to get professional support and automatic update from your WordPress dashboard.'), $this->client->name); ?>
     268                        <?php printf( $this->client->__trans( 'Activate <strong>%s</strong> by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?>
    285269                    </p>
    286                     <form method="post" action="<?php $this->form_action_url(); ?>" novalidate="novalidate" spellcheck="false">
     270                    <form method="post" novalidate="novalidate" spellcheck="false">
    287271                        <input type="hidden" name="_action" value="<?php echo $action; ?>">
    288                         <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce($this->client->name); ?>">
     272                        <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>">
    289273                        <div class="license-input-fields">
    290274                            <div class="license-input-key">
    291275                                <svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
    292                                     <path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z" />
     276                                    <path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z"/>
    293277                                </svg>
    294                                 <input type="text" value="<?php echo $this->get_input_license_value($action, $license); ?>" placeholder="<?php echo esc_attr($this->client->__trans('Enter your license key to activate')); ?>" name="license_key" <?php echo ('deactive' == $action) ? 'readonly="readonly"' : ''; ?> />
     278                                <input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>"
     279                                    placeholder="<?php echo esc_attr( $this->client->__trans( 'Enter your license key to activate' ) ); ?>" name="license_key"
     280                                    <?php echo ( 'deactive' === $action ) ? 'readonly="readonly"' : ''; ?>
     281                                />
    295282                            </div>
    296                             <button type="submit" name="submit" class="<?php echo 'deactive' == $action ? 'deactive-button' : ''; ?>">
    297                                 <?php echo $action == 'active' ? $this->client->__trans('Activate License') : $this->client->__trans('Deactivate License'); ?>
     283                            <button type="submit" name="submit" class="<?php echo 'deactive' === $action ? 'deactive-button' : ''; ?>">
     284                                <?php echo $action === 'active' ? $this->client->__trans( 'Activate License' ) : $this->client->__trans( 'Deactivate License' ); ?>
    298285                            </button>
    299286                        </div>
     
    301288
    302289                    <?php
    303                     if ('deactive' == $action && isset($license['remaining'])) {
    304                         $this->show_active_license_info($license);
    305                     } ?>
     290                    if ( 'deactive' === $action && isset( $license['remaining'] ) ) {
     291                        $this->show_active_license_info( $license );
     292                    }
     293                    ?>
    306294                </div>
    307295            </div> <!-- /.appsero-license-settings -->
    308296
    309             <?php do_action('after_appsero_license_section'); ?>
     297            <?php do_action( 'after_appsero_license_section' ); ?>
    310298        </div>
    311     <?php
     299        <?php
    312300    }
    313301
     
    315303     * License form submit
    316304     */
    317     public function license_form_submit($form)
    318     {
    319         if (!isset($form['_nonce'], $form['_action'])) {
    320             $this->error = $this->client->__trans('Please add all information');
    321 
     305    public function license_form_submit() {
     306        if ( ! isset( $_POST['_nonce'] ) ) {
    322307            return;
    323308        }
    324309
    325         if (!wp_verify_nonce(sanitize_text_field($form['_nonce']), $this->client->name)) {
    326             $this->error = $this->client->__trans("You don't have permission to manage license.");
     310        if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), $this->client->name ) ) {
     311            $this->error = $this->client->__trans( 'Nonce vefification failed.' );
    327312
    328313            return;
    329314        }
    330315
    331         switch (sanitize_text_field($form['_action'])) {
     316        if ( ! current_user_can( 'manage_options' ) ) {
     317            $this->error = $this->client->__trans( 'You don\'t have permission to manage license.' );
     318
     319            return;
     320        }
     321
     322        $license_key = isset( $_POST['license_key'] ) ? sanitize_text_field( wp_unslash( $_POST['license_key'] ) ) : '';
     323        $action      = isset( $_POST['_action'] ) ? sanitize_text_field( wp_unslash( $_POST['_action'] ) ) : '';
     324
     325        switch ( $action ) {
    332326            case 'active':
    333                 $this->active_client_license($form);
     327                $this->active_client_license( $license_key );
    334328                break;
    335329
    336330            case 'deactive':
    337                 $this->deactive_client_license($form);
     331                $this->deactive_client_license();
    338332                break;
    339333
    340334            case 'refresh':
    341                 $this->refresh_client_license($form);
     335                $this->refresh_client_license();
    342336                break;
    343337        }
     
    347341     * Check license status on schedule
    348342     */
    349     public function check_license_status()
    350     {
     343    public function check_license_status() {
    351344        $license = $this->get_license();
    352345
    353         if (isset($license['key']) && !empty($license['key'])) {
    354             $response = $this->check($license['key']);
    355 
    356             if (isset($response['success']) && $response['success']) {
     346        if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) {
     347            $response = $this->check( $license['key'] );
     348
     349            if ( isset( $response['success'] ) && $response['success'] ) {
    357350                $license['status']           = 'activate';
    358351                $license['remaining']        = $response['remaining'];
     
    367360            }
    368361
    369             update_option($this->option_key, $license, false);
     362            update_option( $this->option_key, $license, false );
    370363        }
    371364    }
     
    374367     * Check this is a valid license
    375368     */
    376     public function is_valid()
    377     {
    378         if (null !== $this->is_valid_license) {
     369    public function is_valid() {
     370        if ( null !== $this->is_valid_license ) {
    379371            return $this->is_valid_license;
    380372        }
     
    382374        $license = $this->get_license();
    383375
    384         if (!empty($license['key']) && isset($license['status']) && $license['status'] == 'activate') {
     376        if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) {
    385377            $this->is_valid_license = true;
    386378        } else {
     
    394386     * Check this is a valid license
    395387     */
    396     public function is_valid_by($option, $value)
    397     {
     388    public function is_valid_by( $option, $value ) {
    398389        $license = $this->get_license();
    399390
    400         if (!empty($license['key']) && isset($license['status']) && $license['status'] == 'activate') {
    401             if (isset($license[$option]) && $license[$option] == $value) {
     391        if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) {
     392            if ( isset( $license[ $option ] ) && $license[ $option ] === $value ) {
    402393                return true;
    403394            }
     
    410401     * Styles for licenses page
    411402     */
    412     private function licenses_style()
    413     {
    414     ?>
     403    private function licenses_style() {
     404        ?>
    415405        <style type="text/css">
    416406            .appsero-license-section {
     
    420410                box-sizing: border-box;
    421411            }
    422 
    423412            .appsero-license-settings {
    424413                background-color: #fff;
    425414                box-shadow: 0px 3px 10px rgba(16, 16, 16, 0.05);
    426415            }
    427 
    428416            .appsero-license-settings * {
    429417                box-sizing: border-box;
    430418            }
    431 
    432419            .appsero-license-title {
    433420                background-color: #F8FAFB;
     
    437424                padding: 10px 20px;
    438425            }
    439 
    440426            .appsero-license-title svg {
    441427                width: 30px;
     
    443429                fill: #0082BF;
    444430            }
    445 
    446431            .appsero-license-title span {
    447432                font-size: 17px;
     
    449434                margin-left: 10px;
    450435            }
    451 
    452436            .appsero-license-details {
    453437                padding: 20px;
    454438            }
    455 
    456439            .appsero-license-details p {
    457440                font-size: 15px;
    458441                margin: 0 0 20px 0;
    459442            }
    460 
    461443            .license-input-key {
    462444                position: relative;
     
    464446                max-width: 72%;
    465447            }
    466 
    467448            .license-input-key input {
    468449                background-color: #F9F9F9;
     
    476457                box-shadow: 0 0 0 transparent;
    477458            }
    478 
    479459            .license-input-key input:focus {
    480460                outline: 0 none;
     
    482462                box-shadow: 0 0 0 transparent;
    483463            }
    484 
    485464            .license-input-key svg {
    486465                width: 22px;
     
    491470                top: 13px;
    492471            }
    493 
    494472            .license-input-fields {
    495473                display: flex;
     
    499477                width: 100%;
    500478            }
    501 
    502479            .license-input-fields button {
    503480                color: #fff;
     
    512489                border: 1px solid #0082BF;
    513490            }
    514 
    515491            .license-input-fields button.deactive-button {
    516492                background-color: #E40055;
    517493                border-color: #E40055;
    518494            }
    519 
    520495            .license-input-fields button:focus {
    521496                outline: 0 none;
    522497            }
    523 
    524498            .active-license-info {
    525499                display: flex;
    526500            }
    527 
    528501            .single-license-info {
    529502                min-width: 220px;
    530503                flex: 0 0 30%;
    531504            }
    532 
    533505            .single-license-info h3 {
    534506                font-size: 18px;
    535507                margin: 0 0 12px 0;
    536508            }
    537 
    538509            .single-license-info p {
    539510                margin: 0;
    540511                color: #00C000;
    541512            }
    542 
    543513            .single-license-info p.occupied {
    544514                color: #E40055;
    545515            }
    546 
    547516            .appsero-license-right-form {
    548517                margin-left: auto;
    549518            }
    550 
    551519            .appsero-license-refresh-button {
    552520                padding: 6px 10px 4px 10px;
     
    558526                cursor: pointer;
    559527            }
    560 
    561528            .appsero-license-refresh-button .dashicons {
    562529                color: #fff;
     
    564531            }
    565532        </style>
    566     <?php
     533        <?php
    567534    }
    568535
     
    570537     * Show active license information
    571538     */
    572     private function show_active_license_info($license)
    573     {
    574     ?>
     539    private function show_active_license_info( $license ) {
     540        ?>
    575541        <div class="active-license-info">
    576542            <div class="single-license-info">
    577                 <h3><?php $this->client->_etrans('Activations Remaining'); ?></h3>
    578                 <?php if (empty($license['activation_limit'])) { ?>
    579                     <p><?php $this->client->_etrans('Unlimited'); ?></p>
     543                <h3><?php $this->client->_etrans( 'Activations Remaining' ); ?></h3>
     544                <?php if ( empty( $license['activation_limit'] ) ) { ?>
     545                    <p><?php $this->client->_etrans( 'Unlimited' ); ?></p>
    580546                <?php } else { ?>
    581547                    <p class="<?php echo $license['remaining'] ? '' : 'occupied'; ?>">
    582                         <?php printf($this->client->__trans('%1$d out of %2$d'), $license['remaining'], $license['activation_limit']); ?>
     548                        <?php printf( $this->client->__trans( '%1$d out of %2$d' ), $license['remaining'], $license['activation_limit'] ); ?>
    583549                    </p>
    584550                <?php } ?>
    585551            </div>
    586552            <div class="single-license-info">
    587                 <h3><?php $this->client->_etrans('Expires in'); ?></h3>
     553                <h3><?php $this->client->_etrans( 'Expires in' ); ?></h3>
    588554                <?php
    589                 if (false !== $license['expiry_days']) {
     555                if ( false !== $license['expiry_days'] ) {
    590556                    $occupied = $license['expiry_days'] > 21 ? '' : 'occupied';
    591557                    echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>';
    592558                } else {
    593                     echo '<p>' . $this->client->__trans('Never') . '</p>';
    594                 } ?>
     559                    echo '<p>' . $this->client->__trans( 'Never' ) . '</p>';
     560                }
     561                ?>
    595562            </div>
    596563        </div>
     
    601568     * Show license settings page notices
    602569     */
    603     private function show_license_page_notices()
    604     {
    605         if (!empty($this->error)) {
    606         ?>
     570    private function show_license_page_notices() {
     571        if ( ! empty( $this->error ) ) {
     572            ?>
    607573            <div class="notice notice-error is-dismissible appsero-license-section">
    608574                <p><?php echo $this->error; ?></p>
    609575            </div>
    610         <?php
    611         }
    612 
    613         if (!empty($this->success)) {
    614         ?>
     576            <?php
     577        }
     578
     579        if ( ! empty( $this->success ) ) {
     580            ?>
    615581            <div class="notice notice-success is-dismissible appsero-license-section">
    616582                <p><?php echo $this->success; ?></p>
    617583            </div>
    618         <?php
     584            <?php
    619585        }
    620586        echo '<br />';
     
    624590     * Card header
    625591     */
    626     private function show_license_page_card_header($license)
    627     {
     592    private function show_license_page_card_header( $license ) {
    628593        ?>
    629594        <div class="appsero-license-title">
    630595            <svg enable-background="new 0 0 299.995 299.995" version="1.1" viewBox="0 0 300 300" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
    631                 <path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z" />
    632                 <path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z" />
    633                 <path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z" />
     596                <path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z"/>
     597                <path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z"/>
     598                <path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z"/>
    634599            </svg>
    635             <span><?php echo $this->client->__trans('Activate License'); ?></span>
    636 
    637             <?php if ($license && $license['key']) : ?>
    638                 <form method="post" class="appsero-license-right-form" action="<?php $this->form_action_url(); ?>" novalidate="novalidate" spellcheck="false">
    639                     <input type="hidden" name="_action" value="refresh">
    640                     <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce($this->client->name); ?>">
    641                     <button type="submit" name="submit" class="appsero-license-refresh-button">
    642                         <span class="dashicons dashicons-update"></span>
    643                         <?php echo $this->client->__trans('Refresh License'); ?>
    644                     </button>
    645                 </form>
    646             <?php endif; ?>
     600            <span><?php echo $this->client->__trans( 'Activate License' ); ?></span>
     601
     602            <?php if ( $license && $license['key'] ) { ?>
     603            <form method="post" class="appsero-license-right-form" novalidate="novalidate" spellcheck="false">
     604                <input type="hidden" name="_action" value="refresh">
     605                <input type="hidden" name="_appsero_license_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>">
     606                <button type="submit" name="submit" class="appsero-license-refresh-button">
     607                    <span class="dashicons dashicons-update"></span>
     608                    <?php echo $this->client->__trans( 'Refresh License' ); ?>
     609                </button>
     610            </form>
     611            <?php } ?>
    647612
    648613        </div>
    649 <?php
     614        <?php
    650615    }
    651616
     
    653618     * Active client license
    654619     */
    655     private function active_client_license($form)
    656     {
    657         if (empty($form['license_key'])) {
    658             $this->error = $this->client->__trans('The license key field is required.');
     620    private function active_client_license( $license_key ) {
     621        if ( empty( $license_key ) ) {
     622            $this->error = $this->client->__trans( 'The license key field is required.' );
    659623
    660624            return;
    661625        }
    662626
    663         $license_key = sanitize_text_field($form['license_key']);
    664         $response    = $this->activate($license_key);
    665 
    666         if (!$response['success']) {
    667             $this->error = $response['error'] ? $response['error'] : $this->client->__trans('Unknown error occurred.');
     627        $response = $this->activate( $license_key );
     628
     629        if ( ! $response['success'] ) {
     630            $this->error = $response['error'] ? $response['error'] : $this->client->__trans( 'Unknown error occurred.' );
    668631
    669632            return;
    670633        }
    671634
    672         $data = array(
     635        $data = [
    673636            'key'              => $license_key,
    674637            'status'           => 'activate',
     
    679642            'source_id'        => $response['source_identifier'],
    680643            'recurring'        => $response['recurring'],
    681         );
    682 
    683         update_option($this->option_key, $data, false);
    684        
    685         /**
    686          * Fires after license activated
    687          */
    688         do_action($this->client->slug . '_license_activated', $response);
    689 
    690         $this->success = $this->client->__trans('License activated successfully.');
     644        ];
     645
     646        update_option( $this->option_key, $data, false );
     647
     648        $this->success = $this->client->__trans( 'License activated successfully.' );
    691649    }
    692650
     
    694652     * Deactive client license
    695653     */
    696     private function deactive_client_license($form)
    697     {
     654    private function deactive_client_license() {
    698655        $license = $this->get_license();
    699656
    700         if (empty($license['key'])) {
    701             $this->error = $this->client->__trans('License key not found.');
     657        if ( empty( $license['key'] ) ) {
     658            $this->error = $this->client->__trans( 'License key not found.' );
    702659
    703660            return;
    704661        }
    705662
    706         $response = $this->deactivate(sanitize_text_field($license['key']));
    707 
    708         $data = array(
     663        $response = $this->deactivate( $license['key'] );
     664
     665        $data = [
    709666            'key'    => '',
    710667            'status' => 'deactivate',
    711         );
    712 
    713         update_option($this->option_key, $data, false);
    714 
    715         if (!$response['success']) {
    716             $this->error = $response['error'] ? $response['error'] : $this->client->__trans('Unknown error occurred.');
     668        ];
     669
     670        update_option( $this->option_key, $data, false );
     671
     672        if ( ! $response['success'] ) {
     673            $this->error = $response['error'] ? $response['error'] : $this->client->__trans( 'Unknown error occurred.' );
    717674
    718675            return;
    719676        }
    720677
    721         /**
    722          * Fires after license deactivated
    723          */
    724         do_action($this->client->slug . '_license_deactivated', $response);
    725 
    726         $this->success = $this->client->__trans('License deactivated successfully.');
     678        $this->success = $this->client->__trans( 'License deactivated successfully.' );
    727679    }
    728680
     
    730682     * Refresh Client License
    731683     */
    732     private function refresh_client_license($form = null)
    733     {
     684    private function refresh_client_license() {
    734685        $license = $this->get_license();
    735686
    736         if (!$license || !isset($license['key']) || empty($license['key'])) {
    737             $this->error = $this->client->__trans("License key not found");
     687        if ( ! $license || ! isset( $license['key'] ) || empty( $license['key'] ) ) {
     688            $this->error = $this->client->__trans( 'License key not found' );
     689
    738690            return;
    739691        }
     
    741693        $this->check_license_status();
    742694
    743         /**
    744          * Fires after license refreshed
    745          */
    746         do_action($this->client->slug . '_license_refreshed');
    747 
    748         $this->success = $this->client->__trans('License refreshed successfully.');
     695        $this->success = $this->client->__trans( 'License refreshed successfully.' );
    749696    }
    750697
     
    752699     * Add license menu page
    753700     */
    754     private function create_menu_page()
    755     {
     701    private function create_menu_page() {
    756702        call_user_func(
    757             'add_' . 'menu' . '_page',
     703            'add_menu_page',
    758704            $this->menu_args['page_title'],
    759705            $this->menu_args['menu_title'],
    760706            $this->menu_args['capability'],
    761707            $this->menu_args['menu_slug'],
    762             array($this, 'menu_output'),
     708            [ $this, 'menu_output' ],
    763709            $this->menu_args['icon_url'],
    764710            $this->menu_args['position']
     
    769715     * Add submenu page
    770716     */
    771     private function create_submenu_page()
    772     {
     717    private function create_submenu_page() {
    773718        call_user_func(
    774             'add_' . 'submenu' . '_page',
     719            'add_submenu_page',
    775720            $this->menu_args['parent_slug'],
    776721            $this->menu_args['page_title'],
     
    778723            $this->menu_args['capability'],
    779724            $this->menu_args['menu_slug'],
    780             array($this, 'menu_output'),
     725            [ $this, 'menu_output' ],
    781726            $this->menu_args['position']
    782727        );
     
    786731     * Add submenu page
    787732     */
    788     private function create_options_page()
    789     {
     733    private function create_options_page() {
    790734        call_user_func(
    791             'add_' . 'options' . '_page',
     735            'add_options_page',
    792736            $this->menu_args['page_title'],
    793737            $this->menu_args['menu_title'],
    794738            $this->menu_args['capability'],
    795739            $this->menu_args['menu_slug'],
    796             array($this, 'menu_output'),
     740            [ $this, 'menu_output' ],
    797741            $this->menu_args['position']
    798742        );
     
    802746     * Schedule daily sicense checker event
    803747     */
    804     public function schedule_cron_event()
    805     {
    806         if (!wp_next_scheduled($this->schedule_hook)) {
    807             wp_schedule_event(time(), 'daily', $this->schedule_hook);
    808 
    809             wp_schedule_single_event(time() + 20, $this->schedule_hook);
     748    public function schedule_cron_event() {
     749        if ( ! wp_next_scheduled( $this->schedule_hook ) ) {
     750            wp_schedule_event( time(), 'daily', $this->schedule_hook );
     751
     752            wp_schedule_single_event( time() + 20, $this->schedule_hook );
    810753        }
    811754    }
     
    814757     * Clear any scheduled hook
    815758     */
    816     public function clear_scheduler()
    817     {
    818         wp_clear_scheduled_hook($this->schedule_hook);
     759    public function clear_scheduler() {
     760        wp_clear_scheduled_hook( $this->schedule_hook );
    819761    }
    820762
     
    822764     * Enable/Disable schedule
    823765     */
    824     private function run_schedule()
    825     {
    826         switch ($this->client->type) {
     766    private function run_schedule() {
     767        switch ( $this->client->type ) {
    827768            case 'plugin':
    828                 register_activation_hook($this->client->file, array($this, 'schedule_cron_event'));
    829                 register_deactivation_hook($this->client->file, array($this, 'clear_scheduler'));
     769                register_activation_hook( $this->client->file, [ $this, 'schedule_cron_event' ] );
     770                register_deactivation_hook( $this->client->file, [ $this, 'clear_scheduler' ] );
    830771                break;
    831772
    832773            case 'theme':
    833                 add_action('after_switch_theme', array($this, 'schedule_cron_event'));
    834                 add_action('switch_theme', array($this, 'clear_scheduler'));
     774                add_action( 'after_switch_theme', [ $this, 'schedule_cron_event' ] );
     775                add_action( 'switch_theme', [ $this, 'clear_scheduler' ] );
    835776                break;
    836777        }
     
    838779
    839780    /**
    840      * Form action URL
    841      */
    842     private function form_action_url()
    843     {
    844         $url = add_query_arg(
    845             $_GET,
    846             admin_url(basename($_SERVER['SCRIPT_NAME']))
    847         );
    848 
    849         echo apply_filters('appsero_client_license_form_action', $url);
    850     }
    851 
    852     /**
    853781     * Get input license key
    854782     *
    855      * @param  $action
    856      *
    857783     * @return $license
    858784     */
    859     private function get_input_license_value($action, $license)
    860     {
    861         if ('active' == $action) {
    862             return isset($license['key']) ? $license['key'] : '';
    863         }
    864 
    865         if ('deactive' == $action) {
    866             $key_length = strlen($license['key']);
     785    private function get_input_license_value( $action, $license ) {
     786        if ( 'active' === $action ) {
     787            return isset( $license['key'] ) ? $license['key'] : '';
     788        }
     789
     790        if ( 'deactive' === $action ) {
     791            $key_length = strlen( $license['key'] );
    867792
    868793            return str_pad(
    869                 substr($license['key'], 0, $key_length / 2),
     794                substr( $license['key'], 0, $key_length / 2 ),
    870795                $key_length,
    871796                '*'
  • advance-faq-block/trunk/inc/appsero/src/Updater.php

    r2886650 r2899060  
    11<?php
     2
    23namespace Appsero;
     4
     5use stdClass;
    36
    47/**
     
    1720
    1821    /**
     22     * Cache key
     23     *
     24     * @var string
     25     */
     26    protected $cache_key;
     27
     28    /**
    1929     * Initialize the class
    2030     *
     
    2232     */
    2333    public function __construct( Client $client ) {
    24 
    2534        $this->client    = $client;
    2635        $this->cache_key = 'appsero_' . md5( $this->client->slug ) . '_version_info';
    2736
    2837        // Run hooks.
    29         if ( $this->client->type == 'plugin' ) {
     38        if ( $this->client->type === 'plugin' ) {
    3039            $this->run_plugin_hooks();
    31         } elseif ( $this->client->type == 'theme' ) {
     40        } elseif ( $this->client->type === 'theme' ) {
    3241            $this->run_theme_hooks();
    3342        }
     
    4049     */
    4150    public function run_plugin_hooks() {
    42         add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_plugin_update' ) );
    43         add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
     51        add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_plugin_update' ] );
     52        add_filter( 'plugins_api', [ $this, 'plugins_api_filter' ], 10, 3 );
    4453    }
    4554
     
    5059     */
    5160    public function run_theme_hooks() {
    52         add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_theme_update' ) );
     61        add_filter( 'pre_set_site_transient_update_themes', [ $this, 'check_theme_update' ] );
    5362    }
    5463
     
    6069
    6170        if ( ! is_object( $transient_data ) ) {
    62             $transient_data = new \stdClass;
    63         }
    64 
    65         if ( 'plugins.php' == $pagenow && is_multisite() ) {
     71            $transient_data = new stdClass();
     72        }
     73
     74        if ( 'plugins.php' === $pagenow && is_multisite() ) {
    6675            return $transient_data;
    6776        }
     
    7483
    7584        if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
    76 
    7785            unset( $version_info->sections );
    7886
     
    8593            }
    8694
    87             $transient_data->last_checked = time();
     95            $transient_data->last_checked                       = time();
    8896            $transient_data->checked[ $this->client->basename ] = $this->client->project_version;
    8997        }
     
    95103     * Get version info from database
    96104     *
    97      * @return Object or Boolean
     105     * @return object or Boolean
    98106     */
    99107    private function get_cached_version_info() {
     
    101109
    102110        // If updater page then fetch from API now
    103         if ( 'update-core.php' == $pagenow ) {
     111        if ( 'update-core.php' === $pagenow ) {
    104112            return false; // Force to fetch data
    105113        }
     
    107115        $value = get_transient( $this->cache_key );
    108116
    109         if( ! $value && ! isset( $value->name ) ) {
     117        if ( ! $value && ! isset( $value->name ) ) {
    110118            return false; // Cache is expired
    111119        }
     
    143151     */
    144152    private function get_project_latest_version() {
    145 
    146153        $license = $this->client->license()->get_license();
    147154
    148         $params = array(
     155        $params = [
    149156            'version'     => $this->client->project_version,
    150157            'name'        => $this->client->name,
     
    152159            'basename'    => $this->client->basename,
    153160            'license_key' => ! empty( $license ) && isset( $license['key'] ) ? $license['key'] : '',
    154         );
     161        ];
    155162
    156163        $route = 'update/' . $this->client->hash . '/check';
     
    186193     * Updates information on the "View version x.x details" page with custom data.
    187194     *
    188      * @param mixed   $data
    189      * @param string  $action
    190      * @param object  $args
     195     * @param mixed  $data
     196     * @param string $action
     197     * @param object $args
    191198     *
    192199     * @return object $data
    193200     */
    194201    public function plugins_api_filter( $data, $action = '', $args = null ) {
    195 
    196         if ( $action != 'plugin_information' ) {
     202        if ( $action !== 'plugin_information' ) {
    197203            return $data;
    198204        }
    199205
    200         if ( ! isset( $args->slug ) || ( $args->slug != $this->client->slug ) ) {
     206        if ( ! isset( $args->slug ) || ( $args->slug !== $this->client->slug ) ) {
    201207            return $data;
    202208        }
     
    212218
    213219        if ( ! is_object( $transient_data ) ) {
    214             $transient_data = new \stdClass;
    215         }
    216 
    217         if ( 'themes.php' == $pagenow && is_multisite() ) {
     220            $transient_data = new stdClass();
     221        }
     222
     223        if ( 'themes.php' === $pagenow && is_multisite() ) {
    218224            return $transient_data;
    219225        }
     
    226232
    227233        if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
    228 
    229234            // If new version available then set to `response`
    230235            if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) {
     
    235240            }
    236241
    237             $transient_data->last_checked = time();
     242            $transient_data->last_checked                   = time();
    238243            $transient_data->checked[ $this->client->slug ] = $this->client->project_version;
    239244        }
     
    255260        return $version_info;
    256261    }
    257 
    258262}
  • advance-faq-block/trunk/readme.txt

    r2886650 r2899060  
    33Tags: FAQ block, Gutenberg block, Gutenberg FAQ block, Frequently Asked Questions, FAQs, FAQ section
    44Requires at least: 6.1
    5 Tested up to: 6.1
     5Tested up to: 6.2
    66Requires PHP: 7.0
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPL-2.0+
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    1616
    1717== Screenshots ==
    18 
    19 2. Screenshot_1.png
     181. FAQ Block
    2019
    2120== Changelog ==
    2221
     22= 1.0.2 =
     23- Tested WP 6.2 Compatibility
     24- Updated: Appsero update
     25
    2326= 1.0.1 =
    24 * Intrigate Appsero
     27- Intrigate Appsero
    2528
    2629= 1.0.0 =
    27 * Release
     30- Release
    2831
    2932
Note: See TracChangeset for help on using the changeset viewer.