| @@ -1,55 +1,40 @@ | ||
| 1 | 1 | <?php |
| 2 | +require_once trailingslashit( CFF_PLUGIN_DIR ) . 'admin/addon-functions.php'; | |
| 2 | 3 | |
| 3 | -use CustomFacebookFeed\Builder\CFF_Feed_Builder; | |
| 4 | +require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/Helpers/PluginSilentUpgrader.php'; | |
| 5 | +require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/Helpers/PluginSilentUpgraderSkin.php'; | |
| 6 | +require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/Admin/CFF_Install_Skin.php'; | |
| 4 | 7 | |
| 5 | -if (! defined('ABSPATH')) { | |
| 6 | - exit; // Exit if accessed directly | |
| 7 | -} | |
| 8 | 8 | |
| 9 | -require_once trailingslashit(CFF_PLUGIN_DIR) . 'admin/addon-functions.php'; | |
| 9 | +function cff_ppca_token_check_flag() { | |
| 10 | + check_ajax_referer( 'cff_nonce' , 'cff_nonce'); | |
| 10 | 11 | |
| 11 | -require_once trailingslashit(CFF_PLUGIN_DIR) . 'inc/Helpers/PluginSilentUpgrader.php'; | |
| 12 | -require_once trailingslashit(CFF_PLUGIN_DIR) . 'inc/Helpers/PluginSilentUpgraderSkin.php'; | |
| 13 | -require_once trailingslashit(CFF_PLUGIN_DIR) . 'inc/Admin/CFF_Install_Skin.php'; | |
| 14 | - | |
| 15 | - | |
| 16 | -function cff_ppca_token_check_flag() | |
| 17 | -{ | |
| 18 | - check_ajax_referer('cff_nonce', 'cff_nonce'); | |
| 19 | - | |
| 20 | - $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; | |
| 21 | - $cap = apply_filters('cff_settings_pages_capability', $cap); | |
| 22 | - if (! current_user_can($cap)) { | |
| 12 | + $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options'; | |
| 13 | + $cap = apply_filters( 'cff_settings_pages_capability', $cap ); | |
| 14 | + if ( ! current_user_can( $cap ) ) { | |
| 23 | 15 | wp_send_json_error(); // This auto-dies. |
| 24 | 16 | } |
| 25 | 17 | |
| 26 | - if (get_transient('cff_ppca_access_token_invalid')) { | |
| 27 | - print_r(true); | |
| 28 | - } else { | |
| 29 | - print_r(false); | |
| 30 | - } | |
| 18 | + if( get_transient('cff_ppca_access_token_invalid') ){ | |
| 19 | + print_r(true); | |
| 20 | + } else { | |
| 21 | + print_r(false); | |
| 22 | + } | |
| 31 | 23 | |
| 32 | - die(); | |
| 24 | + die(); | |
| 33 | 25 | } |
| 34 | -add_action('wp_ajax_cff_ppca_token_check_flag', 'cff_ppca_token_check_flag'); | |
| 26 | +add_action( 'wp_ajax_cff_ppca_token_check_flag', 'cff_ppca_token_check_flag' ); | |
| 35 | 27 | |
| 36 | -add_action('admin_enqueue_scripts', 'enqueue_admin_scripts_assets'); | |
| 37 | -function enqueue_admin_scripts_assets() | |
| 38 | -{ | |
| 28 | +add_action( 'admin_enqueue_scripts' , 'enqueue_admin_scripts_assets' ); | |
| 29 | +function enqueue_admin_scripts_assets(){ | |
| 39 | 30 | wp_register_style( |
| 40 | - 'cff-tokens-local', | |
| 41 | - CFF_PLUGIN_URL . 'assets/tokens/cff-tokens-local.css', | |
| 42 | - array(), | |
| 43 | - CFFVER | |
| 44 | - ); | |
| 45 | - wp_register_style( | |
| 46 | 31 | 'custom_wp_admin_css', |
| 47 | 32 | CFF_PLUGIN_URL . 'admin/assets/css/cff-admin-style.css', |
| 48 | - array('cff-tokens-local'), | |
| 33 | + false, | |
| 49 | 34 | CFFVER |
| 50 | 35 | ); |
| 51 | - wp_enqueue_style('custom_wp_admin_css'); | |
| 36 | + wp_enqueue_style( 'custom_wp_admin_css' ); | |
| 52 | 37 | wp_enqueue_style( |
| 53 | 38 | 'cff-font-awesome', |
| 54 | 39 | 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', |
| 55 | 40 | array(), |
| @@ -62,38 +47,37 @@ | ||
| 62 | 47 | false, |
| 63 | 48 | CFFVER |
| 64 | 49 | ); |
| 65 | 50 | |
| 66 | - wp_localize_script('cff_admin_script', 'cffA', array( | |
| 67 | - 'ajax_url' => admin_url('admin-ajax.php'), | |
| 68 | - 'cff_nonce' => wp_create_nonce('cff_nonce') | |
| 69 | - )); | |
| 51 | + wp_localize_script( 'cff_admin_script', 'cffA', array( | |
| 52 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 53 | + 'cff_nonce' => wp_create_nonce( 'cff_nonce' ) | |
| 54 | + ) | |
| 55 | +); | |
| 70 | 56 | $strings = array( |
| 71 | - 'addon_activate' => esc_html__('Activate', 'custom-facebook-feed'), | |
| 72 | - 'addon_activated' => esc_html__('Activated', 'custom-facebook-feed'), | |
| 73 | - 'addon_active' => esc_html__('Active', 'custom-facebook-feed'), | |
| 74 | - 'addon_deactivate' => esc_html__('Deactivate', 'custom-facebook-feed'), | |
| 75 | - 'addon_inactive' => esc_html__('Inactive', 'custom-facebook-feed'), | |
| 76 | - 'addon_install' => esc_html__('Install Addon', 'custom-facebook-feed'), | |
| 77 | - 'addon_error' => esc_html__('Could not install addon. Please download from smashballoon.com and install manually.', 'custom-facebook-feed'), | |
| 78 | - 'plugin_error' => esc_html__('Could not install a plugin. Please download from WordPress.org and install manually.', 'custom-facebook-feed'), | |
| 79 | - 'addon_search' => esc_html__('Searching Addons', 'custom-facebook-feed'), | |
| 80 | - 'ajax_url' => admin_url('admin-ajax.php'), | |
| 81 | - 'cancel' => esc_html__('Cancel', 'custom-facebook-feed'), | |
| 82 | - 'close' => esc_html__('Close', 'custom-facebook-feed'), | |
| 83 | - 'nonce' => wp_create_nonce('cff-admin'), | |
| 84 | - 'almost_done' => esc_html__('Almost Done', 'custom-facebook-feed'), | |
| 85 | - 'oops' => esc_html__('Oops!', 'custom-facebook-feed'), | |
| 86 | - 'ok' => esc_html__('OK', 'custom-facebook-feed'), | |
| 87 | - 'plugin_install_activate_btn' => esc_html__('Install and Activate', 'custom-facebook-feed'), | |
| 88 | - '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'), | |
| 89 | - 'plugin_activate_btn' => esc_html__('Activate', 'custom-facebook-feed'), | |
| 90 | - 'oembed_connectionURL' => cffGetOembedConnectionUrl(), | |
| 91 | - 'smashPlugins' => CFF_Feed_Builder::get_smashballoon_plugins_info() | |
| 57 | + 'addon_activate' => esc_html__( 'Activate', 'custom-facebook-feed' ), | |
| 58 | + 'addon_activated' => esc_html__( 'Activated', 'custom-facebook-feed' ), | |
| 59 | + 'addon_active' => esc_html__( 'Active', 'custom-facebook-feed' ), | |
| 60 | + 'addon_deactivate' => esc_html__( 'Deactivate', 'custom-facebook-feed' ), | |
| 61 | + 'addon_inactive' => esc_html__( 'Inactive', 'custom-facebook-feed' ), | |
| 62 | + 'addon_install' => esc_html__( 'Install Addon', 'custom-facebook-feed' ), | |
| 63 | + 'addon_error' => esc_html__( 'Could not install addon. Please download from smashballoon.com and install manually.', 'custom-facebook-feed' ), | |
| 64 | + 'plugin_error' => esc_html__( 'Could not install a plugin. Please download from WordPress.org and install manually.', 'custom-facebook-feed' ), | |
| 65 | + 'addon_search' => esc_html__( 'Searching Addons', 'custom-facebook-feed' ), | |
| 66 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 67 | + 'cancel' => esc_html__( 'Cancel', 'custom-facebook-feed' ), | |
| 68 | + 'close' => esc_html__( 'Close', 'custom-facebook-feed' ), | |
| 69 | + 'nonce' => wp_create_nonce( 'cff-admin' ), | |
| 70 | + 'almost_done' => esc_html__( 'Almost Done', 'custom-facebook-feed' ), | |
| 71 | + 'oops' => esc_html__( 'Oops!', 'custom-facebook-feed' ), | |
| 72 | + 'ok' => esc_html__( 'OK', 'custom-facebook-feed' ), | |
| 73 | + 'plugin_install_activate_btn' => esc_html__( 'Install and Activate', 'custom-facebook-feed' ), | |
| 74 | + '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' ), | |
| 75 | + 'plugin_activate_btn' => esc_html__( 'Activate', 'custom-facebook-feed' ), | |
| 92 | 76 | ); |
| 93 | - $strings = apply_filters('cff_admin_strings', $strings); | |
| 77 | + $strings = apply_filters( 'cff_admin_strings', $strings ); | |
| 94 | 78 | wp_localize_script( |
| 95 | 79 | 'cff_admin_script', |
| 96 | 80 | 'cff_admin', |
| 97 | 81 | $strings |
| 98 | 82 | ); |
| 99 | -} | |
| 83 | +} | |