=')){ 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 ''; } } /** * Get the layout for the page. classic|2-col * */ function get_page_layout( ) { $layout = 'classic'; foreach ( seed_csp4_get_options() as $v ) { switch ( $v[ 'type' ] ) { case 'menu'; $page = $_REQUEST[ 'page' ]; if ( $page == $v[ 'menu_slug' ] ) { if ( isset( $v[ 'layout' ] ) ) { $layout = $v[ 'layout' ]; } } break; } } return $layout; } /** * Render the option pages. * * @since 0.1.0 */ function option_page( ) { $menu_slug = null; $page = $_REQUEST[ 'page' ]; $layout = $this->get_page_layout(); ?>

Coming Soon Page and Maintenance Mode Lite Version

plugin_options_tabs(); ?>
$_GET['tab'])); ?>
'; $this->do_settings_sections( $v[ 'id' ],$show_submit ); echo '
'; } else { do_settings_sections( $v[ 'id' ] ); } } break; } } } ?>






$v ) { switch ( $v[ 'type' ] ) { case 'menu': $menu_slug = $v[ 'menu_slug' ]; break; case 'setting': if ( empty( $v[ 'validate_function' ] ) ) { $v[ 'validate_function' ] = array( &$this, 'validate_machine' ); } register_setting( $v[ 'id' ], $v[ 'id' ], $v[ 'validate_function' ] ); $setting_id = $v[ 'id' ]; break; case 'section': if ( empty( $v[ 'desc_callback' ] ) ) { $v[ 'desc_callback' ] = array( &$this, 'return_empty_string' ); } else { $v[ 'desc_callback' ] = $v[ 'desc_callback' ]; } add_settings_section( $v[ 'id' ], $v[ 'label' ], $v[ 'desc_callback' ], $v[ 'id' ] ); $section_id = $v[ 'id' ]; break; case 'tab': break; default: if ( empty( $v[ 'callback' ] ) ) { $v[ 'callback' ] = array( &$this, 'field_machine' ); } add_settings_field( $v[ 'id' ], $v[ 'label' ], $v[ 'callback' ], $section_id, $section_id, array( 'id' => $v[ 'id' ], 'desc' => ( isset( $v[ 'desc' ] ) ? $v[ 'desc' ] : '' ), 'setting_id' => $setting_id, 'class' => ( isset( $v[ 'class' ] ) ? $v[ 'class' ] : '' ), 'type' => $v[ 'type' ], 'default_value' => ( isset( $v[ 'default_value' ] ) ? $v[ 'default_value' ] : '' ), 'option_values' => ( isset( $v[ 'option_values' ] ) ? $v[ 'option_values' ] : '' ) ) ); } } } /** * Create a field based on the field type passed in. * * @since 0.1.0 */ function field_machine( $args ) { extract( $args ); //$id, $desc, $setting_id, $class, $type, $default_value, $option_values // Load defaults $defaults = array( ); foreach ( seed_csp4_get_options() as $k ) { switch ( $k[ 'type' ] ) { case 'setting': case 'section': case 'tab': break; default: if ( isset( $k[ 'default_value' ] ) ) { $defaults[ $k[ 'id' ] ] = $k[ 'default_value' ]; } } } $options = get_option( $setting_id ); $options = wp_parse_args( $options, $defaults ); $path = SEED_CSP4_PLUGIN_PATH . 'framework/field-types/' . $type . '.php'; if ( file_exists( $path ) ) { // Show Field include( $path ); // Show description if ( !empty( $desc ) ) { echo "{$desc}"; } } } /** * Validates user input before we save it via the Options API. If error add_setting_error * * @since 0.1.0 * @param array $input Contains all the values submitted to the POST. * @return array $input Contains sanitized values. * @todo Figure out best way to validate values. */ function validate_machine( $input ) { $option_page = $_POST['option_page']; foreach ( seed_csp4_get_options() as $k ) { switch ( $k[ 'type' ] ) { case 'menu': case 'setting': if(isset($k['id'])) $setting_id = $k['id']; case 'section': case 'tab'; break; default: if ( !empty( $k[ 'validate' ] ) && $setting_id == $option_page ) { $validation_rules = explode( ',', $k[ 'validate' ] ); foreach ( $validation_rules as $v ) { $path = SEED_CSP4_PLUGIN_PATH . 'framework/validations/' . $v . '.php'; if ( file_exists( $path ) ) { // Defaults Values $is_valid = true; $error_msg = ''; // Test Validation include( $path ); // Is it valid? if ( $is_valid === false ) { add_settings_error( $k[ 'id' ], 'seedprod_error', $error_msg, 'error' ); // Unset invalids unset( $input[ $k[ 'id' ] ] ); } } } //end foreach } } } return $input; } /** * Dummy function to be called by all sections from the Settings API. Define a custom function in the config. * * @since 0.1.0 * @return string Empty */ function return_empty_string( ) { echo ''; } /** * SeedProd version of WP's do_settings_sections * * @since 0.1.0 */ function do_settings_sections( $page, $show_submit ) { global $wp_settings_sections, $wp_settings_fields; if ( !isset( $wp_settings_sections ) || !isset( $wp_settings_sections[ $page ] ) ) return; foreach ( (array) $wp_settings_sections[ $page ] as $section ) { echo "

{$section['title']}

\n"; echo '
'; call_user_func( $section[ 'callback' ], $section ); if ( !isset( $wp_settings_fields ) || !isset( $wp_settings_fields[ $page ] ) || !isset( $wp_settings_fields[ $page ][ $section[ 'id' ] ] ) ) continue; echo ''; $this->do_settings_fields( $page, $section[ 'id' ] ); echo '
'; if($show_submit): ?>

'; } } 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 ''; if ( !empty($field['args']['label_for']) ) echo ''; else echo '' . $field['title'] . ''; echo ''; call_user_func($field['callback'], $field['args']); echo ''; echo ''; } } } add_action( 'admin_head', 'seed_csp4_set_user_settings' ); function seed_csp4_set_user_settings() { if(isset($_GET['page']) && $_GET['page'] == 'seed_csp4'){ $user_id = get_current_user_id(); $options = get_user_option( 'user-settings', $user_id ); parse_str($options,$user_settings); $user_settings['imgsize'] = 'full'; update_user_option( $user_id, 'user-settings', http_build_query($user_settings), false ); update_user_option( $user_id, 'user-settings-time', time(), false ); } }