Skip to content

Commit

Permalink
Add plugin support as a feature due to issues with smart detection. See
Browse files Browse the repository at this point in the history
  • Loading branch information
markoheijnen committed Nov 22, 2015
1 parent 5e207d6 commit 6057632
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
80 changes: 80 additions & 0 deletions features/plugin-support/plugin-support.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

class Tabify_Edit_Screen_Feature_Plugin_Support {

public function __construct() {
$screen = get_current_screen();

if ( 'settings_page_tabify-edit-screen' != $screen->base ) {
return;
}

add_action( 'tabify_add_meta_boxes', array( $this, 'types' ) );
add_action( 'tabify_add_meta_boxes', array( $this, 'members' ) );
add_action( 'tabify_add_meta_boxes', array( $this, 'wpml' ) );

add_filter( 'wpseo_always_register_metaboxes_on_admin', '__return_true' );
add_action( 'tabify_add_meta_boxes', array( $this, 'wpseo' ) ); // The old way, will be removed in 1.0
}

/**
* Load widgets created by Types
*
* @param string $posttype The posttype the metaboxes should be loaded from
*
* @since 0.4.0
*/
public function types( $posttype ) {
if ( function_exists( 'wpcf_admin_post_page_load_hook' ) ) {
$_GET['post_type'] = $posttype;
wpcf_admin_post_page_load_hook();
unset( $_GET['post_type'] );
}
}

/**
* Load widgets created by WordPress SEO
*
* @param string $posttype The posttype the metaboxes should be loaded from
*
* @since 0.4.0
*/
public function wpseo( $posttype ) {
if ( defined( 'WPSEO_PATH' ) && is_file( WPSEO_PATH . 'admin/class-metabox.php' ) ) {
include_once WPSEO_PATH . 'admin/class-metabox.php';
}
}


/**
* Load widgets created by Members
*
* @param string $posttype The posttype the metaboxes should be loaded from
*
* @since 0.4.0
*/
public function members( $posttype ) {
if ( function_exists( 'members_admin_setup' ) && ! did_action( 'load-post.php' ) ) {
do_action( 'load-post.php' );
}
}

/**
* Load widgets created by Members
*
* @param string $posttype The posttype the metaboxes should be loaded from
*
* @since 0.7.0
*/
public function wpml( $posttype ) {
global $sitepress, $post;

if ( defined('ICL_SITEPRESS_VERSION') && $sitepress && ! $post ) {
$post = (object) array( 'post_type' => $posttype );
$sitepress->post_edit_language_options();

$post = null;
}
}

}
6 changes: 5 additions & 1 deletion tabify-edit-screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ public function load_features( $screen ) {
'permissions'
);

if ( apply_filters( 'tabify_plugin_support', true ) ) {
$features[] = 'plugin-support';
}

foreach ( $features as $feature ) {
$class_name = 'Tabify_Edit_Screen_Feature_' . $feature;
$class_name = 'Tabify_Edit_Screen_Feature_' . str_replace( '-', '_', $feature );

include 'features/' . $feature . '/' . $feature . '.php';
new $class_name;
Expand Down

0 comments on commit 6057632

Please sign in to comment.