array( 'post_type_name' => 'premise_split_view', 'singular' => 'Split View', 'plural' => 'Split Views', 'slug' => 'split-view', ), 'args' => array( 'supports' => array( 'title' ), ), ); /** * Constructor. Intentionally left empty and public. * * @see setup() * @since 1.0 */ public function __construct() {} /** * Access this plugin’s working instance * * @since 1.0 * @return object instance of this class */ public static function get_instance() { null === self::$instance and self::$instance = new self; return self::$instance; } /** * Setup Premise * * Does includes and registers hooks. * * @since 1.0 */ public function setup() { $this->includes(); if ( class_exists( 'PremiseCPT' ) ) { new PremiseCPT( $this->cpt_args['name'] , $this->cpt_args['args'] ); add_action( 'admin_enqueue_scripts' , array( $this , 'admin_scripts' ) ); add_action( 'wp_enqueue_scripts' , array( $this , 'fe_scripts' ) ); add_filter( 'the_content' , array( PSV_Render_View::get_instance() , 'init' ) ); add_action( 'admin_footer' , array( PSV_CPT_UI::get_instance() , 'insert_footer' ) ); add_shortcode( 'pwp_splitview' , array( PSV_Shortcode::get_instance() , 'init' ) ); pwp_add_metabox( array( 'title' => 'Premise SPlit View', 'callback' => array( PSV_CPT_UI::get_instance(), 'split_view_ui' ) ), 'premise_split_view', '', 'premise_split_view' ); // Add rewrite flush rules on init with a higher priority than 10. // if we created the cpt. add_action( 'init', array( $this, 'psv_maybe_flush_rules' ), 11 ); } } /** * Include all necessary files for our plugin to work properly. */ public function includes() { // Require Premise WP. if ( ! class_exists( 'Premise_WP' ) ) { // Require Premise WP plugin with the help of TGM Plugin Activation. require_once PREMISE_SPLITV_PATH . 'includes/class-tgm-plugin-activation.php'; add_action( 'tgmpa_register', array( $this, 'pwpsv_register_required_plugins' ) ); return; } include 'classes/class-cpt-ui.php'; include 'classes/class-render.php'; include 'classes/class-shortcode.php'; } /** * Resgisters admin scripts * * @return void does not return anything */ public function admin_scripts() { wp_register_style( 'psv_admin_css', $this->plugin_url . '/css/admin/psv-admin.min.css' ); wp_enqueue_style( 'psv_admin_css' ); wp_register_script( 'psv_admin_js', $this->plugin_url . '/js/admin/psv-admin.min.js' ); wp_enqueue_script( 'psv_admin_js' ); } /** * Resgister the front end scripts * * @return void does not return anything */ public function fe_scripts() { wp_register_style( 'psv_fe_css', $this->plugin_url . '/css/style.min.css' ); wp_enqueue_style( 'psv_fe_css' ); wp_register_script( 'psv_fe_js', $this->plugin_url . '/js/frontend/psv-fe.min.js', array( 'jquery' ) ); wp_enqueue_script( 'psv_fe_js' ); } /** * Install * * @since 1.0.2 * * @param boolean $networkwide Network wide?. */ public static function do_install( $networkwide ) { // Save an option in the DB when this plugin gets installed to flush rewrite rules on init. if ( ! get_option( '_psv_activation_happened' ) ) add_option( '_psv_activation_happened', true ); } /** * Flush rewrite rules if our plugin was just activated. * * @since 1.0.2 * * @return void does not return anything */ public function psv_maybe_flush_rules() { // If this option exists we just activated the plugin, flush rewrite rules. if ( get_option( '_psv_activation_happened' ) ) { flush_rewrite_rules(); // Delete the option so we dont flush rules again. delete_option( '_psv_activation_happened' ); } } /** * Register the required plugins for this theme. * * We register one plugin: * - Premise-WP from a GitHub repository * * @link https://github.com/PremiseWP/Premise-WP */ public function pwpsv_register_required_plugins() { /* * Array of plugin arrays. Required keys are name and slug. * If the source is NOT from the .org repo, then source is also required. */ $plugins = array( array( 'name' => 'Premise-WP', 'slug' => 'Premise-WP', 'source' => 'https://github.com/PremiseWP/Premise-WP/archive/master.zip', 'required' => true, 'force_activation' => false, ), ); /* * Array of configuration settings. */ $config = array( 'id' => 'pwpsv-tgmpa', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'parent_slug' => 'plugins.php', 'capability' => 'install_plugins', 'has_notices' => true, 'dismissable' => false, 'dismiss_msg' => '', 'is_automatic' => true, 'message' => '', ); tgmpa( $plugins, $config ); } }