=')){ add_action( 'wpms_tgmpa_register', 'coming_soon_init_recommendations' ); } } if (defined( 'DOING_AJAX' )){ // Background API Ajax add_action( 'wp_ajax_seed_csp4_backgrounds', array(&$this,'backgrounds')); } } /** * Return an instance of this class. * * @since 1.0.0 * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if ( null == self::$instance ) { self::$instance = new self; } return self::$instance; } /** * backgrounds api * */ function backgrounds( ) { if(check_ajax_referer('seed_csp4_backgrounds')){ $r = array(); $page = ''; if(isset($_REQUEST['page'])){ $page = $_REQUEST['page']; $page = '?page='.$page; $r['page'] = $_REQUEST['page']; } $query = ''; if(isset($_REQUEST['query'])){ $query = $_REQUEST['query']; $query = '?query='.$query; $r['query'] = $_REQUEST['query']; } if ( false === ( get_transient( 'seed_csp4_backgrounds_page_'.$query.$page ) ) ) { //f(1){ //echo 'miss'; $bg_api = 'https://api.seedprod.com/v3/free_background_search'; $url = $bg_api.'?'.http_build_query($r); $response = wp_remote_get( $url ); //var_dump($url); if ( is_wp_error( $response ) ) { $error_message = $response->get_error_message(); echo "Something went wrong: $error_message"; }else{ $response_code = wp_remote_retrieve_response_code( $response ); if($response_code == '200'){ set_transient('seed_csp4_backgrounds_page_'.$query.$page,$response['body'],604800); echo $response['body']; }else{ echo 'There was an issue loading the stock images. Please try again later.'; } } }else{ //echo 'hit'; echo get_transient( 'seed_csp4_backgrounds_page_'.$query.$page ); } exit(); } } /** * Reset the settings page. Reset works per settings id. * */ function reset_defaults( ) { if ( isset( $_POST[ 'seed_csp4_reset' ] ) ) { $option_page = $_POST[ 'option_page' ]; check_admin_referer( $option_page . '-options' ); require_once(SEED_CSP4_PLUGIN_PATH.'inc/default-settings.php'); $_POST[ $_POST[ 'option_page' ] ] = $seed_csp4_settings_deafults[$_POST[ 'option_page' ]]; add_settings_error( 'general', 'seed_csp4-settings-reset', __( "Settings reset." ), 'updated' ); } } /** * Properly enqueue styles and scripts for our theme options page. * * This function is attached to the admin_enqueue_scripts action hook. * * @since 0.1.0 * @param string $hook_suffix The name of the current page we are on. */ function admin_enqueue_scripts( $hook_suffix ) { if (strpos($hook_suffix, 'seed_csp4') === false ) return; wp_enqueue_script( 'media-upload' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'wp-lists' ); wp_enqueue_script( 'seed_csp4-framework-js', SEED_CSP4_PLUGIN_URL . 'framework/settings-scripts.js', array( 'jquery' ), $this->plugin_version ); wp_enqueue_script( 'seed_csp4-magnific-popup-js', SEED_CSP4_PLUGIN_URL . 'public/vendor/magnific-popup/jquery.magnific-popup.min.js', array( 'jquery' ), $this->plugin_version ); wp_enqueue_script( 'theme-preview' ); wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'media-upload' ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'seed_csp4-framework-css', SEED_CSP4_PLUGIN_URL . 'framework/settings-style.css', false, $this->plugin_version ); wp_enqueue_style( 'font-awesome-solid', SEED_CSP4_PLUGIN_URL . 'public/vendor/fontawesome/css/solid.min.css', false, $this->plugin_version, false, $this->plugin_version ); wp_enqueue_style( 'font-awesome', SEED_CSP4_PLUGIN_URL . 'public/vendor/fontawesome/css/fontawesome.min.css', false, $this->plugin_version, false, $this->plugin_version ); wp_enqueue_style( 'seed_csp4-magnific-popup-js', SEED_CSP4_PLUGIN_URL . 'public/vendor/magnific-popup/magnific-popup.css', false, $this->plugin_version, false, $this->plugin_version ); } /** * Creates WordPress Menu pages from an array in the config file. * * This function is attached to the admin_menu action hook. * * @since 0.1.0 */ function create_menus( ) { add_menu_page( __( "SeedProd", 'coming-soon' ), __( "SeedProd", 'coming-soon' ), 'manage_options', 'seed_csp4', array( &$this , 'option_page' ), SEED_CSP4_PLUGIN_URL . 'public/images/menu-logo.png', 200 ); add_submenu_page( 'seed_csp4', __( "Settings", 'coming-soon' ), __( "Settings", 'coming-soon' ), 'manage_options', 'seed_csp4', array( &$this , 'option_page' ) ); add_submenu_page( 'seed_csp4', __( "Themes", 'coming-soon' ), __( "Themes", 'coming-soon' ), 'manage_options', 'seed_csp4_themes', array( &$this , 'themes_page' ) ); add_submenu_page( 'seed_csp4', __( "Free Stock Images", 'coming-soon' ), __( "Free Stock Images", 'coming-soon' ), 'manage_options', 'seed_csp4_stockimages', array( &$this , 'stockimages_page' ) ); add_submenu_page( 'seed_csp4', __( "Subscribers", 'coming-soon' ), __( "Subscribers", 'coming-soon' ), 'manage_options', 'seed_csp4_subscribers', array( &$this , 'subscribers_page' ) ); add_submenu_page( 'seed_csp4', __( "Addons", 'coming-soon' ), __( "Addons", 'coming-soon' ), 'manage_options', 'seed_csp4_addons', array( &$this , 'addons_page' ) ); } function themes_page(){ include SEED_CSP4_PLUGIN_PATH.'resources/views/themes.php'; } function stockimages_page(){ include SEED_CSP4_PLUGIN_PATH.'resources/views/stockimages.php'; } function subscribers_page(){ include SEED_CSP4_PLUGIN_PATH.'resources/views/subscribers.php'; } function addons_page(){ include SEED_CSP4_PLUGIN_PATH.'resources/views/addons.php'; } /** * Display settings link on plugin page */ function plugin_action_links( $links, $file ) { $plugin_file = SEED_CSP4_SLUG; if ( $file == $plugin_file ) { $settings_link = 'Settings'; array_unshift( $links, $settings_link ); } return $links; } /** * Allow Tabs on the Settings Page * */ function plugin_options_tabs( ) { $menu_slug = null; $page = $_REQUEST[ 'page' ]; $uses_tabs = false; $current_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : false; //Check if this config uses tabs foreach ( seed_csp4_get_options() as $v ) { if ( $v[ 'type' ] == 'tab' ) { $uses_tabs = true; break; } } // If uses tabs then generate the tabs if ( $uses_tabs ) { echo '
'; } } function do_settings_fields($page, $section) { global $wp_settings_fields; if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) return; foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { echo '