Skip to content

Commit

Permalink
Prevent some connectors from loading on the site frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Carbis committed Nov 2, 2016
1 parent c6ed40c commit ed3a635
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 1 deletion.
14 changes: 14 additions & 0 deletions classes/class-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ abstract class Connector {
*/
public $prev_stream = null;

/**
* Register connector in the WP Admin
*
* @var bool
*/
public $register_admin = true;

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = true;

/**
* Register all context hooks
*/
Expand Down
15 changes: 14 additions & 1 deletion classes/class-connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,22 @@ public function load_connectors() {
continue;
}
$class = new $class_name( $this->plugin->log );
if ( ! method_exists( $class, 'is_dependency_satisfied' ) ) {

// Check if the Connector extends WP_Stream\Connector
if ( ! is_subclass_of( $class, 'WP_Stream\Connector' ) ) {
continue;
}

// Check if the Connector is allowed to be registered in the WP Admin
if ( is_admin() && ! $class->register_admin ) {
continue;
}

// Check if the Connector is allowed to be registered in the WP Frontend
if ( ! is_admin() && ! $class->register_frontend ) {
continue;
}

if ( $class->is_dependency_satisfied() ) {
$classes[ $class->name ] = $class;
}
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class Connector_Editor extends Connector {
*/
private $edited_file = array();

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Register all context hooks
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ class Connector_Installer extends Connector {
'_core_updated_successfully',
);

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Return translated connector label
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class Connector_Jetpack extends Connector {
'wp_ajax_jetpack_post_by_email_disable',
);

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Tracked option keys
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class Connector_Menus extends Connector {
'delete_nav_menu',
);

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Return translated connector label
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class Connector_Posts extends Connector {
'deleted_post',
);

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Return translated connector label
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ class Connector_Settings extends Connector {
'new_admin_email',
);

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Register all context hooks
*
Expand Down
7 changes: 7 additions & 0 deletions connectors/class-connector-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class Connector_Taxonomies extends Connector {
*/
public $context_labels;

/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = false;

/**
* Return translated connector label
*
Expand Down

0 comments on commit ed3a635

Please sign in to comment.