admin_url( 'admin-ajax.php' ), 'plugin_url' => admin_url( 'plugins.php' ), 'nonce' => wp_create_nonce( 'ayyash-admin' ), ) ); } /** * Recommended Plugins */ public static function recommended_plugins() { $plugins = apply_filters( 'ayyash_recommended_plugins', array( array( 'slug' => 'ayyash-studio', 'icon' => 'icon.svg', 'name' => __( 'Ayyash Studio — The kick-start kit', 'ayyash' ), 'file' => 'ayyash-studio/ayyash-studio.php', ), array( 'slug' => 'elementor', 'icon' => 'icon.svg', 'name' => __( 'Elementor', 'ayyash' ), 'file' => 'elementor/elementor.php', ), array( 'slug' => 'absolute-addons', 'icon' => 'icon-256x256.png', 'name' => __( 'Absolute Addons', 'ayyash' ), 'file' => 'absolute-addons/absolute-addons.php', ), array( 'slug' => 'absolute-thumbnail-column', 'icon' => 'icon-256x256.png', 'name' => __( 'Absolute Thumbnail Column', 'ayyash' ), 'file' => 'absolute-thumbnail-column/absolute-thumbnail-column.php', ), array( 'slug' => 'regenerate-thumbnails', 'icon' => 'icon-256x256..png', 'name' => __( 'Regenerate Thumbnails', 'ayyash' ), 'file' => 'regenerate-thumbnails/regenerate-thumbnails.php', ), ) ); return $plugins; } /** * Returns an Array of all the Available Google Fonts * * @return array */ public static function ayyash_docs_data() { static $docs; if ( null === $docs ) { /** @define "AYYASH_THEME_DIR" "./../../" */ $docs = file_get_contents( AYYASH_THEME_DIR . 'assets/docs.json' ); if ( $docs ) { $docs = json_decode( $docs, true ); } } return $docs ? $docs : []; } /** * Menu Callback */ public static function ayyash_content_callback() { self::ayyash_options_header(); ?>
Ayyash
$tab ) { printf( '%2$s', esc_attr( $slug ), esc_html( $tab['menu_title'] ) ); } ?>
[ 'menu_title' => esc_html__( 'Recommended Plugins', 'ayyash' ), 'position' => - 1, ], 'theme-documentation' => [ 'menu_title' => esc_html__( 'Documentation', 'ayyash' ), 'position' => 10, ], ]; uasort( $tabs, [ __CLASS__, 'ayyash_options_uasort_position' ] ); return $tabs; } /** * Tab Content */ protected static function get_tab_content() { ?>
$tab ) { ?>
get_error_message() ); } wp_send_json_success( __( 'Plugin Activated Successfully!', 'ayyash' ) ); } wp_send_json_error(); } /** * Ajax Deactivating Plugin * * @return void */ public static function ajax_deactivate_plugin() { check_ajax_referer( 'ayyash-admin', 'nonce' ); $mainfile = ( isset( $_POST['mainfile'] ) ) ? sanitize_text_field( wp_unslash( $_POST['mainfile'] ) ) : false; if ( $mainfile && current_user_can( 'install_plugins' ) ) { deactivate_plugins( $mainfile, false, false ); if ( ! is_plugin_inactive( $mainfile ) ) { wp_send_json_error( __( 'Cannot deactivate this plugin!', 'ayyash' ) ); } wp_send_json_success( __( 'Plugin Deactivated Successfully!', 'ayyash' ) ); } wp_send_json_error(); } /** * Return plugin is inactive , not installed and update. * * @return array */ public static function plugin_status() { $recommended_plugins = self::recommended_plugins(); $installed_plugins = apply_filters( 'all_plugins', get_plugins() ); $plugin_status = []; $plugin_status['msg']['not_installed'] = _n_noop( 'This theme recommends the following plugin: ', 'This theme recommends the following plugins: ', 'ayyash' ); $plugin_status['msg']['not_active'] = _n_noop( 'The following recommended plugin is currently inactive: ', 'The following recommended plugins are currently inactive: ', 'ayyash' ); $plugin_status['msg']['updates'] = _n_noop( 'There is an update available for: ', 'There are updates available for the following plugins: ', 'ayyash' ); foreach ( $recommended_plugins as $plugin ) { $is_installed = isset( $installed_plugins[ $plugin['file'] ] ); $is_active = is_plugin_active( $plugin['file'] ); if ( ! $is_installed ) { $plugin_status['not_installed'][ $plugin['name'] ] = sprintf('%s', esc_url( admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=772&height=239"') ), esc_html( $plugin['name'] ) ); } if ( ! $is_active && $is_installed ) { $plugin_status['not_active'][ $plugin['name'] ] = sprintf('%s', esc_url( admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=772&height=239"') ), esc_html( $plugin['name'] ) ); } $repo_updates = get_site_transient( 'update_plugins' ); if ( isset( $repo_updates->response[ $plugin['file'] ]->new_version ) ) { $plugin_status['updates'][ $plugin['name'] ] = sprintf('%s', esc_url( admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=772&height=239"') ), esc_html( $plugin['name'] ) ); } } return $plugin_status; } /** * Delete dismissable nag option when theme is switched. * * This ensures that the user(s) is/are again reminded via nag of required * and/or recommended plugins if they re-activate the theme. */ public function update_dismiss() { delete_metadata( 'user', null, 'ayyash_required_plugin_dismiss_notice', null, true ); } /** * Register dismissal of admin notices. * * Acts on the dismiss link in the admin nag messages. * If clicked, the admin notice disappears and will no longer be visible to this user. */ public function dismiss() { if ( isset( $_GET['ayyash-required-dismiss'] ) && check_admin_referer( 'ayyash-required-dismiss-' . get_current_user_id() ) ) { update_user_meta( get_current_user_id(), 'ayyash_required_plugin_dismiss_notice', 1 ); } } /** * Comma Seperated String generator * * @param $array * * @return string */ public static function notice_str_generator( $array = [] ) { return join(' and ', array_filter( array_merge( array( join(', ', array_slice( $array, 0, -1) ) ), array_slice( $array, -1) ), 'strlen') ); } /** * Ayyash Admin Notice * * @return void */ public static function ayyash_author_admin_notice() { $plugin_status = self::plugin_status(); //Check user compatibility for notices. if ( ! current_user_can( 'install_plugins' ) && ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'update_plugins' ) ) { return; } //Check User is dismissed the notice. if ( 1 === intval( get_user_meta( get_current_user_id(), 'ayyash_required_plugin_dismiss_notice', true ) ) ) { return; } //Check there is any plugin status if ( 0 === count( $plugin_status ) ) { return; } $styles = 'display: block; margin: 0.5em 0.5em 0 0; clear: both;'; ?>