Traits
4 years ago
CFF_About.php
4 years ago
CFF_About_Us.php
4 years ago
CFF_Admin.php
4 years ago
CFF_Global_Settings.php
4 years ago
CFF_Install_Skin.php
5 years ago
CFF_New_User.php
4 years ago
CFF_Notifications.php
4 years ago
CFF_Support.php
4 years ago
CFF_Tracking.php
4 years ago
CFF_Upgrader.php
4 years ago
CFF_oEmbeds.php
4 years ago
CFF_Admin.php
219 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CFF_Admin plugin. |
| 4 | * |
| 5 | * Contains everything about the Admin area |
| 6 | * |
| 7 | * @since 2.19 |
| 8 | */ |
| 9 | |
| 10 | namespace CustomFacebookFeed\Admin; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 13 | |
| 14 | |
| 15 | class CFF_Admin{ |
| 16 | |
| 17 | /** |
| 18 | * Admin constructor |
| 19 | * |
| 20 | * @since 2.19 |
| 21 | */ |
| 22 | public function __construct(){ |
| 23 | $this->admin_hook(); |
| 24 | $this->register_assets(); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | /** |
| 29 | * Admin Hooks + Enqueue |
| 30 | * |
| 31 | * @since 2.19 |
| 32 | */ |
| 33 | protected function admin_hook(){ |
| 34 | //Adding Dashboard Menu |
| 35 | add_action( 'admin_menu', array( $this, 'register_dashboard_menus' ), 9 ); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Register CFF dashboard Menus. |
| 41 | * |
| 42 | * @since 2.19 |
| 43 | */ |
| 44 | public function register_dashboard_menus(){ |
| 45 | $notice = ''; |
| 46 | if ( \cff_main()->cff_error_reporter->are_critical_errors() ) { |
| 47 | $notice = ' <span class="cff-notice-alert"><span>!</span></span>'; |
| 48 | } |
| 49 | |
| 50 | $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options'; |
| 51 | $cap = apply_filters( 'cff_settings_pages_capability', $cap ); |
| 52 | |
| 53 | $sbi_notifications = new CFF_Notifications(); |
| 54 | $notifications = $sbi_notifications->get(); |
| 55 | |
| 56 | $notice_bubble = ''; |
| 57 | if ( empty( $notice ) && ! empty( $notifications ) && is_array( $notifications ) ) { |
| 58 | $notice_bubble = ' <span class="cff-notice-alert"><span>'.count( $notifications ).'</span></span>'; |
| 59 | } |
| 60 | |
| 61 | add_menu_page( |
| 62 | 'Facebook Feed', |
| 63 | 'Facebook Feed'. $notice . $notice_bubble, |
| 64 | $cap, |
| 65 | 'cff-top', |
| 66 | 'cff_settings_page' |
| 67 | ); |
| 68 | |
| 69 | add_submenu_page( |
| 70 | 'cff-top', |
| 71 | __( 'Upgrade to Pro', 'custom-facebook-feed' ), |
| 72 | __( '<span class="cff_get_pro">Try the Pro Demo</span>', 'custom-facebook-feed' ), |
| 73 | $cap, |
| 74 | 'https://smashballoondemo.com/?utm_campaign=facebook-free&utm_source=menu-link&utm_medium=upgrade-link', |
| 75 | '' |
| 76 | ); |
| 77 | |
| 78 | //Show a Instagram plugin menu item if it isn't already installed |
| 79 | if( !is_plugin_active( 'instagram-feed/instagram-feed.php' ) && !is_plugin_active( 'instagram-feed-pro/instagram-feed.php' ) && current_user_can( 'activate_plugins' ) && current_user_can( 'install_plugins' ) ){ |
| 80 | add_submenu_page( |
| 81 | 'cff-top', |
| 82 | __( 'Instagram Feed', 'custom-facebook-feed' ), |
| 83 | '<span class="cff_get_sbi">' . __( 'Instagram Feed', 'custom-facebook-feed' ) . '</span>', |
| 84 | $cap, |
| 85 | 'admin.php?page=cff-top&tab=more', |
| 86 | '' |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | //Show a Twitter plugin menu item if it isn't already installed |
| 91 | if( !is_plugin_active( 'custom-twitter-feeds/custom-twitter-feed.php' ) && !is_plugin_active( 'custom-twitter-feeds-pro/custom-twitter-feed.php' ) && current_user_can( 'activate_plugins' ) && current_user_can( 'install_plugins' ) ){ |
| 92 | add_submenu_page( |
| 93 | 'cff-top', |
| 94 | __( 'Twitter Feed', 'custom-facebook-feed' ), |
| 95 | '<span class="cff_get_ctf">' . __( 'Twitter Feed', 'custom-facebook-feed' ) . '</span>', |
| 96 | $cap, |
| 97 | 'admin.php?page=cff-top&tab=more', |
| 98 | '' |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | //Show a YouTube plugin menu item if it isn't already installed |
| 103 | if( !is_plugin_active( 'feeds-for-youtube/youtube-feed.php' ) && !is_plugin_active( 'youtube-feed-pro/youtube-feed.php' ) && current_user_can( 'activate_plugins' ) && current_user_can( 'install_plugins' ) ){ |
| 104 | add_submenu_page( |
| 105 | 'cff-top', |
| 106 | __( 'YouTube Feed', 'custom-facebook-feed' ), |
| 107 | '<span class="cff_get_yt">' . __( 'YouTube Feed', 'custom-facebook-feed' ) . '</span>', |
| 108 | $cap, |
| 109 | 'admin.php?page=cff-top&tab=more', |
| 110 | '' |
| 111 | ); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Register Assets |
| 117 | * |
| 118 | * @since 2.19 |
| 119 | */ |
| 120 | public function register_assets(){ |
| 121 | add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_styles_assets' ) ); |
| 122 | add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_scripts_assets' ) ); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * Enqueue & Register Styles |
| 129 | * |
| 130 | * @since 2.19 |
| 131 | */ |
| 132 | public function enqueue_styles_assets(){ |
| 133 | wp_register_style( |
| 134 | 'custom_wp_admin_css', |
| 135 | CFF_PLUGIN_URL . 'admin/assets/css/cff-admin-style.css', |
| 136 | false, |
| 137 | CFFVER |
| 138 | ); |
| 139 | wp_enqueue_style( 'custom_wp_admin_css' ); |
| 140 | wp_enqueue_style( |
| 141 | 'cff-font-awesome', |
| 142 | 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', |
| 143 | array(), |
| 144 | '4.5.0' |
| 145 | ); |
| 146 | wp_enqueue_style( 'wp-color-picker' ); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /** |
| 151 | * Enqueue & Register Scripts |
| 152 | * |
| 153 | * @since 2.19 |
| 154 | */ |
| 155 | public function enqueue_scripts_assets(){ |
| 156 | //Declare color-picker as a dependency |
| 157 | wp_enqueue_script( |
| 158 | 'cff_admin_script', |
| 159 | CFF_PLUGIN_URL . 'admin/assets/js/cff-admin-scripts.js', |
| 160 | false, |
| 161 | CFFVER |
| 162 | ); |
| 163 | |
| 164 | wp_localize_script( 'cff_admin_script', 'cffA', array( |
| 165 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 166 | 'cff_nonce' => wp_create_nonce( 'cff_nonce' ) |
| 167 | ) |
| 168 | ); |
| 169 | $strings = array( |
| 170 | 'addon_activate' => esc_html__( 'Activate', 'custom-facebook-feed' ), |
| 171 | 'addon_activated' => esc_html__( 'Activated', 'custom-facebook-feed' ), |
| 172 | 'addon_active' => esc_html__( 'Active', 'custom-facebook-feed' ), |
| 173 | 'addon_deactivate' => esc_html__( 'Deactivate', 'custom-facebook-feed' ), |
| 174 | 'addon_inactive' => esc_html__( 'Inactive', 'custom-facebook-feed' ), |
| 175 | 'addon_install' => esc_html__( 'Install Addon', 'custom-facebook-feed' ), |
| 176 | 'addon_error' => esc_html__( 'Could not install addon. Please download from smashballoon.com and install manually.', 'custom-facebook-feed' ), |
| 177 | 'plugin_error' => esc_html__( 'Could not install a plugin. Please download from WordPress.org and install manually.', 'custom-facebook-feed' ), |
| 178 | 'addon_search' => esc_html__( 'Searching Addons', 'custom-facebook-feed' ), |
| 179 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 180 | 'cancel' => esc_html__( 'Cancel', 'custom-facebook-feed' ), |
| 181 | 'close' => esc_html__( 'Close', 'custom-facebook-feed' ), |
| 182 | 'nonce' => wp_create_nonce( 'cff-admin' ), |
| 183 | 'almost_done' => esc_html__( 'Almost Done', 'custom-facebook-feed' ), |
| 184 | 'oops' => esc_html__( 'Oops!', 'custom-facebook-feed' ), |
| 185 | 'ok' => esc_html__( 'OK', 'custom-facebook-feed' ), |
| 186 | 'plugin_install_activate_btn' => esc_html__( 'Install and Activate', 'custom-facebook-feed' ), |
| 187 | 'plugin_install_activate_confirm' => esc_html__( 'needs to be installed and activated to import its forms. Would you like us to install and activate it for you?', 'custom-facebook-feed' ), |
| 188 | 'plugin_activate_btn' => esc_html__( 'Activate', 'custom-facebook-feed' ), |
| 189 | ); |
| 190 | $strings = apply_filters( 'cff_admin_strings', $strings ); |
| 191 | |
| 192 | wp_localize_script( |
| 193 | 'cff_admin_script', |
| 194 | 'cff_admin', |
| 195 | $strings |
| 196 | ); |
| 197 | if( !wp_script_is('jquery-ui-draggable') ) { |
| 198 | wp_enqueue_script( |
| 199 | array( |
| 200 | 'jquery', |
| 201 | 'jquery-ui-core', |
| 202 | 'jquery-ui-draggable' |
| 203 | ) |
| 204 | ); |
| 205 | } |
| 206 | wp_enqueue_script( |
| 207 | array( |
| 208 | 'hoverIntent', |
| 209 | 'wp-color-picker' |
| 210 | ) |
| 211 | ); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | } |
| 219 |