*/ class AffiGet_Admin { const OPTION_USER_KEY = 'afg_user_key'; /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Bookmarklet is responsible for maintaining and registering all hooks that power * the bookmarklet. * * @since 1.0.0 * @access protected * @var AffiGet_Admin_Bookmarklet $bookmarklet Maintains and registers all hooks for the Afg+ bookmarklet. */ protected $bookmarklet; /** * Admin_Amazon is responsible for maintaining and registering all hooks that power * the Amazon API. * * @since 1.0.0 * @access protected * @var AffiGet_Admin_Amazon $amazon Makes calls to Amazon Product API. */ protected $amazon; /** * Initialize the class and set its properties. * * @since 1.0.0 * @var string $plugin_name The name of this plugin. * @var string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->bookmarklet = new AffiGet_Admin_Bookmarklet(); $this->amazon = new AffiGet_Admin_Amazon(); add_action( 'admin_enqueue_scripts', array(&$this, 'enqueue_admin_scripts_for_pointers' )); } /** * * @return AffiGet_Admin_Amazon */ public function get_amazon(){ return $this->amazon; } public function get_bookmarklet(){ return $this->bookmarklet; } public function admin_menu() { add_options_page( __('AffiGet Settings', 'afg'), apply_filters('afg_admin_settings_menu_title', 'AffiGet Mini'), 'manage_options', 'affiget-settings-page', array( $this, 'settings_page' ) ); } public function settings_page(){?>

amazon->settings_section(); echo '

'; do_action('afg_admin__page_after_amazon'); $this->bookmarklet->settings_section(); echo '

'; do_action('afg_admin__settings_page_bottom'); ?>
plugin_name, plugin_dir_url( __FILE__ ) . 'css/affiget-admin.css', array(), $this->version, 'all' ); if ( 'post.php' != $hook ) { return; } $screen = get_current_screen(); $meta = AffiGet_Review_Meta::get_instance(); if ( $screen->post_type == $meta->post_type_name ){ wp_enqueue_script( $this->plugin_name.'-post-style', admin_url('admin-ajax.php?action=afg_get_admin_post_css&post='.(isset($_GET['post'])?$_GET['post']:'')), array( 'jquery', 'afg-raty-style' ), $this->version, false ); } } /** * Register the JavaScript for the dashboard. * * @since 1.0.0 */ public function enqueue_scripts( $hook ) { /** * An instance of this class should be passed to the run() function * defined in AffiGet_Admin_Loader as all of the hooks are defined * in that particular class. * * The AffiGet_Admin_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/affiget-admin.js', array( 'jquery' ), $this->version, false ); if ( 'post.php' != $hook ) { return; } $screen = get_current_screen(); $meta = AffiGet_Review_Meta::get_instance(); if ( $screen->post_type == $meta->post_type_name ){ wp_enqueue_script( 'afg-admin-post-script', admin_url('admin-ajax.php?action=afg_get_admin_post_js&post='.(isset($_GET['post'])?$_GET['post']:'')), array( 'jquery', 'afg-raty-script' ), $this->version, false ); } } static function output_cacheable_css( $css, $expiration_in_minutes = 5 ){ ob_start(); echo $css; header("Content-type: text/css"); header('Content-Length: ' . ob_get_length()); if( ! $expiration_in_minutes ){ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } else { $expires = 60 * $expiration_in_minutes; //DAY_IN_S; // 60 * 60 * 24 ... defined elsewhere header('Cache-Control: max-age='.$expires.', must-revalidate'); header('Pragma: public'); header('Expires: '. gmdate('D, d M Y H:i:s', time()+$expires).' GMT'); } ob_end_flush(); return; } static function output_cacheable_js( $js, $expiration_in_minutes = 5 ){ ob_start(); echo $js; header("Content-type: application/javascript"); header('Content-Length: ' . ob_get_length()); if( ! $expiration_in_minutes ){ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false ); header("Pragma: no-cache"); } else { $expires = 60 * $expiration_in_minutes; //DAY_IN_S; // 60 * 60 * 24 ... defined elsewhere header('Cache-Control: max-age='.$expires.', must-revalidate'); header('Expires: '. gmdate('D, d M Y H:i:s', time()+$expires).' GMT'); header('Pragma: public'); } ob_end_flush(); return; } static function output_cacheable_json( $data, $expiration_in_minutes = 5 ){ ob_start(); echo json_encode( $data ); header("Content-type: application/json"); header('Content-Length: ' . ob_get_length()); if( ! $expiration_in_minutes ){ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } else { $expires = 60 * $expiration_in_minutes; //DAY_IN_S; // 60 * 60 * 24 ... defined elsewhere header('Cache-Control: max-age='.$expires.', must-revalidate'); header('Pragma: public'); header('Expires: '. gmdate('D, d M Y H:i:s', time()+$expires).' GMT'); } ob_end_flush(); return; } function enqueue_admin_scripts_for_pointers() { $seen_it = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); $do_add_script = false; if( ! in_array( 'afg00', $seen_it ) ) { $do_add_script = true; // Each pointer has its own function responsible for putting appropriate JavaScript into footer add_action( 'admin_print_footer_scripts', array( &$this, 'pointer_afg00_footer_script' ) ); } elseif( ! in_array( 'afg01', $seen_it ) ) { $do_add_script = true; add_action( 'admin_print_footer_scripts', array( &$this, 'pointer_afg01_footer_script' ) ); } if( $do_add_script ) { // add JavaScript for WP Pointers wp_enqueue_script( 'wp-pointer' ); // add CSS for WP Pointers wp_enqueue_style( 'wp-pointer' ); } } function pointer_afg00_footer_script() { $ptn = AffiGet_Review_Meta::get_instance()->post_type_name; $link = admin_url('edit.php?post_type=' . $ptn ); // Build the main content of your pointer balloon in a variable $pointer_content = '

'.__('AffiGet Reviews','afg').'

'; // Title should be

for proper formatting. $pointer_content .= '

'; $pointer_content .= sprintf( __('AffiGet enables a new post type, called %s.
The only way to create new reviews is by means of the AffiGet Bookmarklet', 'afg'), '' . esc_html__('Reviews', 'afg') . '' ); $pointer_content .= '

'; ?> '.__('AffiGet Setup','afg').'

'; // Title should be

for proper formatting. $pointer_content .= '

'; $pointer_content .= sprintf( __('To start posting your reviews,
please complete %s.', 'afg'), '' . esc_html__('AffiGet Settings','afg') . '' ); $pointer_content .= '

'; //to provide your license key, and your details for Amazon Associates account ?> '; //print_r(compact('links', 'plugin_file', 'plugin_data', 'context')); //echo ''; if ( 'affiget-mini/affiget-mini.php' == $plugin_file || 'affiget-pro/affiget-pro.php' == $plugin_file ) { $new_link = sprintf('%s', admin_url('options-general.php?page=affiget-settings-page'), esc_html__('Settings', 'afg') ); // make the 'Settings' link appear first $first_link = array_shift( $links ); array_unshift( $links, $new_link ); array_unshift( $links, $first_link ); } return $links; } } /* EOF */