| @@ -1,14 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | +namespace WPAdminify\Libs; | |
| 2 | 3 | |
| 3 | -namespace PXLBSAdminify\Libs; | |
| 4 | - | |
| 5 | 4 | // No, Direct access Sir !!! |
| 6 | -if (!defined('ABSPATH')) { | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | 6 | exit; |
| 8 | 7 | } |
| 9 | 8 | |
| 10 | -if (!class_exists('Featured')) { | |
| 9 | +if ( ! class_exists( 'Featured' ) ) { | |
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Featured global class |
| 14 | 13 | * |
| @@ -13,29 +12,16 @@ | ||
| 13 | 12 | * Featured global class |
| 14 | 13 | * |
| 15 | 14 | * Jewel Theme <support@jeweltheme.com> |
| 16 | 15 | */ |
| 17 | - class Featured | |
| 18 | - { | |
| 16 | + class Featured { | |
| 19 | 17 | |
| 20 | 18 | /** |
| 21 | 19 | * Constructor |
| 22 | 20 | */ |
| 23 | - public function __construct() | |
| 24 | - { | |
| 25 | - add_action('plugins_loaded', [$this, 'loaded_plgins']); | |
| 26 | - } | |
| 27 | - | |
| 28 | - | |
| 29 | - /** | |
| 30 | - * Plugins Loaded Function | |
| 31 | - * | |
| 32 | - * @return void | |
| 33 | - */ | |
| 34 | - public function loaded_plgins() | |
| 35 | - { | |
| 36 | - if (is_admin()) { | |
| 37 | - add_filter('install_plugins_table_api_args_featured', array($this, 'featured_plugins_tab')); | |
| 21 | + public function __construct() { | |
| 22 | + if ( is_admin() ) { | |
| 23 | + add_filter( 'install_plugins_table_api_args_featured', array( $this, 'jltwp_adminify_featured_plugins_tab' ) ); | |
| 38 | 24 | } |
| 39 | 25 | } |
| 40 | 26 | |
| 41 | 27 | /** |
| @@ -42,11 +28,10 @@ | ||
| 42 | 28 | * Helper function for adding plugins to fav list. |
| 43 | 29 | * |
| 44 | 30 | * @param [type] $args . |
| 45 | 31 | */ |
| 46 | - public function featured_plugins_tab($args) | |
| 47 | - { | |
| 48 | - add_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 3); | |
| 32 | + public function jltwp_adminify_featured_plugins_tab( $args ) { | |
| 33 | + add_filter( 'plugins_api_result', array( $this, 'jltwp_adminify_plugins_api_result' ), 10, 3 ); | |
| 49 | 34 | |
| 50 | 35 | return $args; |
| 51 | 36 | } |
| 52 | 37 | |
| @@ -56,18 +41,17 @@ | ||
| 56 | 41 | * @param [type] $res . |
| 57 | 42 | * @param [type] $action . |
| 58 | 43 | * @param [type] $args . |
| 59 | 44 | */ |
| 60 | - public function plugins_api_result($res, $action, $args) | |
| 61 | - { | |
| 62 | - remove_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 1); | |
| 45 | + public function jltwp_adminify_plugins_api_result( $res, $action, $args ) { | |
| 46 | + remove_filter( 'plugins_api_result', array( $this, 'jltwp_adminify_plugins_api_result' ), 10, 1 ); | |
| 63 | 47 | |
| 64 | 48 | // Plugin list which you want to show as feature in dashboard. |
| 65 | - // $res = $this->add_plugin_favs('image-hover-effects-elementor-addon', $res); . | |
| 66 | - $res = $this->add_plugin_favs('ultimate-blocks-for-gutenberg', $res); | |
| 67 | - $res = $this->add_plugin_favs('adminify', $res); | |
| 68 | - $res = $this->add_plugin_favs('master-addons', $res); | |
| 69 | - | |
| 49 | + // $res = $this->jltwp_adminify_add_plugin_favs('image-hover-effects-elementor-addon', $res); . | |
| 50 | + $res = $this->jltwp_adminify_add_plugin_favs( 'ultimate-blocks-for-gutenberg', $res ); | |
| 51 | + $res = $this->jltwp_adminify_add_plugin_favs( 'adminify', $res ); | |
| 52 | + $res = $this->jltwp_adminify_add_plugin_favs( 'master-addons', $res ); | |
| 53 | + | |
| 70 | 54 | return $res; |
| 71 | 55 | } |
| 72 | 56 | |
| 73 | 57 | /** |
| @@ -75,13 +59,12 @@ | ||
| 75 | 59 | * |
| 76 | 60 | * @param [type] $plugin_slug . |
| 77 | 61 | * @param [type] $res . |
| 78 | 62 | */ |
| 79 | - public function add_plugin_favs($plugin_slug, $res) | |
| 80 | - { | |
| 81 | - if (!empty($res->plugins) && is_array($res->plugins)) { | |
| 82 | - foreach ($res->plugins as $plugin) { | |
| 83 | - if (is_object($plugin) && !empty($plugin->slug) && $plugin_slug === $plugin->slug) { | |
| 63 | + public function jltwp_adminify_add_plugin_favs( $plugin_slug, $res ) { | |
| 64 | + if ( ! empty( $res->plugins ) && is_array( $res->plugins ) ) { | |
| 65 | + foreach ( $res->plugins as $plugin ) { | |
| 66 | + if ( is_object( $plugin ) && ! empty( $plugin->slug ) && $plugin_slug === $plugin->slug ) { | |
| 84 | 67 | return $res; |
| 85 | 68 | } |
| 86 | 69 | } // foreach |
| 87 | 70 | } |
| @@ -86,10 +69,10 @@ | ||
| 86 | 69 | } // foreach |
| 87 | 70 | } |
| 88 | 71 | |
| 89 | 72 | $plugin_info = new \stdClass(); |
| 90 | - if (get_transient('pxlbsadminify-plugin-info-' . $plugin_slug == $plugin_info)) { | |
| 91 | - array_unshift($res->plugins, $plugin_info); | |
| 73 | + if ( get_transient( 'jltwp_adminify-plugin-info-' . $plugin_slug == $plugin_info ) ) { | |
| 74 | + array_unshift( $res->plugins, $plugin_info ); | |
| 92 | 75 | } else { |
| 93 | 76 | $plugin_info = plugins_api( |
| 94 | 77 | 'plugin_information', |
| 95 | 78 | array( |
| @@ -105,11 +88,11 @@ | ||
| 105 | 88 | ), |
| 106 | 89 | ) |
| 107 | 90 | ); |
| 108 | 91 | |
| 109 | - if (!is_wp_error($plugin_info)) { | |
| 92 | + if ( ! is_wp_error( $plugin_info ) ) { | |
| 110 | 93 | $res->plugins[] = $plugin_info; |
| 111 | - set_transient('pxlbsadminify-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7); | |
| 94 | + set_transient( 'jltwp_adminify-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7 ); | |
| 112 | 95 | } |
| 113 | 96 | } |
| 114 | 97 | |
| 115 | 98 | return $res; |
| @@ -114,5 +97,5 @@ | ||
| 114 | 97 | |
| 115 | 98 | return $res; |
| 116 | 99 | } |
| 117 | 100 | } |
| 118 | -} | |
| 101 | +} | |