| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. |
| 2 |
/** |
| 3 |
* |
| 4 |
* Setup Framework Class |
| 5 |
* |
| 6 |
* @since 1.0.0 |
| 7 |
* @version 1.0.0 |
| 8 |
* |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'CSF_Welcome' ) ) { |
| 11 |
class CSF_Welcome{ |
| 12 |
|
| 13 |
private static $instance = null; |
| 14 |
|
| 15 |
public function __construct() { |
| 16 |
|
| 17 |
if ( CSF::$premium && ( ! CSF::is_active_plugin( 'codestar-framework/codestar-framework.php' ) || apply_filters( 'csf_welcome_page', true ) === false ) ) { return; } |
| 18 |
|
| 19 |
add_action( 'admin_menu', array( $this, 'add_about_menu' ), 0 ); |
| 20 |
add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 5 ); |
| 21 |
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_row_meta' ), 10, 2 ); |
| 22 |
|
| 23 |
$this->set_demo_mode(); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
// instance |
| 28 |
public static function instance() { |
| 29 |
if ( is_null( self::$instance ) ) { |
| 30 |
self::$instance = new self(); |
| 31 |
} |
| 32 |
return self::$instance; |
| 33 |
} |
| 34 |
|
| 35 |
public function add_about_menu() { |
| 36 |
add_management_page( 'Codestar Framework', 'Codestar Framework', 'manage_options', 'csf-welcome', array( $this, 'add_page_welcome' ) ); |
| 37 |
} |
| 38 |
|
| 39 |
public function add_page_welcome() { |
| 40 |
|
| 41 |
$section = ( ! empty( $_GET['section'] ) ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ''; |
| 42 |
|
| 43 |
CSF::include_plugin_file( 'views/header.php' ); |
| 44 |
|
| 45 |
// safely include pages |
| 46 |
switch ( $section ) { |
| 47 |
|
| 48 |
case 'quickstart': |
| 49 |
CSF::include_plugin_file( 'views/quickstart.php' ); |
| 50 |
break; |
| 51 |
|
| 52 |
case 'documentation': |
| 53 |
CSF::include_plugin_file( 'views/documentation.php' ); |
| 54 |
break; |
| 55 |
|
| 56 |
case 'relnotes': |
| 57 |
CSF::include_plugin_file( 'views/relnotes.php' ); |
| 58 |
break; |
| 59 |
|
| 60 |
case 'support': |
| 61 |
CSF::include_plugin_file( 'views/support.php' ); |
| 62 |
break; |
| 63 |
|
| 64 |
case 'free-vs-premium': |
| 65 |
CSF::include_plugin_file( 'views/free-vs-premium.php' ); |
| 66 |
break; |
| 67 |
|
| 68 |
default: |
| 69 |
CSF::include_plugin_file( 'views/about.php' ); |
| 70 |
break; |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
CSF::include_plugin_file( 'views/footer.php' ); |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
public static function add_plugin_action_links( $links, $plugin_file ) { |
| 79 |
|
| 80 |
if ( $plugin_file === 'codestar-framework/codestar-framework.php' && ! empty( $links ) ) { |
| 81 |
$links['csf--welcome'] = '<a href="'. esc_url( admin_url( 'tools.php?page=csf-welcome' ) ) .'">Settings</a>'; |
| 82 |
if ( ! CSF::$premium ) { |
| 83 |
$links['csf--upgrade'] = '<a href="http://codestarframework.com/">Upgrade</a>'; |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
return $links; |
| 88 |
|
| 89 |
} |
| 90 |
|
| 91 |
public static function add_plugin_row_meta( $links, $plugin_file ) { |
| 92 |
|
| 93 |
if ( $plugin_file === 'codestar-framework/codestar-framework.php' && ! empty( $links ) ) { |
| 94 |
$links['csf--docs'] = '<a href="http://codestarframework.com/documentation/" target="_blank">Documentation</a>'; |
| 95 |
} |
| 96 |
|
| 97 |
return $links; |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
public function set_demo_mode() { |
| 102 |
|
| 103 |
$demo_mode = get_option( 'csf_demo_mode', false ); |
| 104 |
|
| 105 |
$demo_activate = ( ! empty( $_GET[ 'csf-demo' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'csf-demo' ] ) ) : ''; |
| 106 |
|
| 107 |
if ( ! empty( $demo_activate ) ) { |
| 108 |
|
| 109 |
$demo_mode = ( $demo_activate === 'activate' ) ? true : false; |
| 110 |
|
| 111 |
update_option( 'csf_demo_mode', $demo_mode ); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
if ( ! empty( $demo_mode ) ) { |
| 116 |
|
| 117 |
CSF::include_plugin_file( 'samples/admin-options.php' ); |
| 118 |
|
| 119 |
if ( CSF::$premium ) { |
| 120 |
|
| 121 |
CSF::include_plugin_file( 'samples/customize-options.php' ); |
| 122 |
CSF::include_plugin_file( 'samples/metabox-options.php' ); |
| 123 |
CSF::include_plugin_file( 'samples/nav-menu-options.php' ); |
| 124 |
CSF::include_plugin_file( 'samples/profile-options.php' ); |
| 125 |
CSF::include_plugin_file( 'samples/shortcode-options.php' ); |
| 126 |
CSF::include_plugin_file( 'samples/taxonomy-options.php' ); |
| 127 |
CSF::include_plugin_file( 'samples/widget-options.php' ); |
| 128 |
CSF::include_plugin_file( 'samples/comment-options.php' ); |
| 129 |
|
| 130 |
} |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
} |
| 135 |
|
| 136 |
} |
| 137 |
|
| 138 |
CSF_Welcome::instance(); |
| 139 |
} |
| 140 |
|