Skip to content

Commit

Permalink
Fix duplication of class instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmhendricks committed Dec 17, 2018
1 parent afa7205 commit 3385b98
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function __construct() {
add_filter( 'body_class', array( $this, 'add_body_classes' ) );

// Example - Remove Emoji code from header
if( !$this->is_ajax() && $this->get_carbon_plugin_option( 'remove_header_emojicons' ) ) {
if( $this->get_carbon_plugin_option( 'remove_header_emojicons' ) ) {
add_filter( 'init', array( $this, 'disable_wp_emojicons' ) );
}

Expand Down
2 changes: 0 additions & 2 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public function load_dependencies() {

if( class_exists( 'Carbon_Fields\\Carbon_Fields' ) ) {
add_action( 'after_setup_theme', array( 'Carbon_Fields\\Carbon_Fields', 'boot' ) );
} else {
new TGMPA();
}

add_action( 'carbon_fields_fields_registered', array( $this, 'load_plugin' ));
Expand Down
6 changes: 4 additions & 2 deletions app/PostTypes/Clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public function add_post_type_client() {
Container::make( 'post_meta', 'Contact Info' )
->show_on_post_type( $cpt->name )
->add_fields( array(
Field::make( 'text', $this->prefix( 'url' ), __( 'Web Site', self::$textdomain ) ),
Field::make( 'text', $this->prefix( 'phone' ), __( 'Phone Number', self::$textdomain ) ),
Field::make( 'text', $this->prefix( 'url' ), __( 'Web Site', self::$textdomain ) )
->set_classes( 'carbon-fields-custom-field-url' ),
Field::make( 'text', $this->prefix( 'phone' ), __( 'Phone Number', self::$textdomain ) )
->set_classes( 'carbon-fields-custom-field-tel' ),
Field::make( 'textarea', $this->prefix( 'address' ), __( 'Address', self::$textdomain ) )
->set_rows( 4 )
)
Expand Down
9 changes: 2 additions & 7 deletions app/PostTypes/PostTypes_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ public function __construct() {
Clients::class
);

foreach( $this->posttypes as $posttypesClass ) {

$posttype = new $posttypesClass();
if( $posttype instanceof PostTypeInterface ) {
new $posttype();
}

foreach( $this->posttypes as $postTypesClass ) {
if( class_exists( $postTypesClass ) ) new $postTypesClass();
}

}
Expand Down
9 changes: 1 addition & 8 deletions app/Shortcodes/Shortcode_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ public function __construct() {
);

foreach( $this->shortcodes as $shortcodeClass ) {

$shortcode = new $shortcodeClass();
if( $shortcode instanceof ShortcodeInterface ) {
new $shortcode();
} else {
// Log or show error notices
}

if( class_exists( $shortcodeClass ) ) new $shortcodeClass();
}

}
Expand Down

0 comments on commit 3385b98

Please sign in to comment.