Skip to content

Commit

Permalink
Fixed conflicts when multiple versions installed
Browse files Browse the repository at this point in the history
  • Loading branch information
dmhendricks committed Apr 15, 2018
1 parent 93e4091 commit fc0cab4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
16 changes: 16 additions & 0 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,20 @@ public static function get_wpsac_plugin_option( $key, $group_id = 'options', $ca

}

/**
* Append a field prefix as defined in $config
*
* @param string|null $field_name The string/field to prefix
* @param string $before String to add before the prefix
* @param string $after String to add after the prefix
* @return string Prefixed string/field value
* @since 0.1.0
*/
public static function prefix( $field_name = null, $before = '', $after = '_' ) {

$prefix = $before . self::$config->get( 'prefix' ) . $after;
return $field_name !== null ? $prefix . $field_name : $prefix;

}

}
3 changes: 2 additions & 1 deletion app/Settings/Network_Settings_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function __construct() {
*/
public function create_network_options_page() {

Container::make( 'network', $this->prefix( self::$config->get( 'network/default_options_container' ) ), __( 'Global Settings', self::$textdomain ) )
$container_name = $this->prefix( self::$config->get( 'network/default_options_container' ) );
Container::make( 'network', $container_name, __( 'Global Settings', self::$textdomain ) )
->set_page_parent( 'settings.php' )
->add_tab( __( 'General', self::$textdomain ), array(
Field::make( 'textarea', $this->prefix( 'network_site_footer' ), __( 'WP Admin Site Footer', self::$textdomain ) )
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"jjgrainger/posttypes": "^2.0",
"tgmpa/tgm-plugin-activation": "^2.6.1",
"tareq1988/wordpress-settings-api-class": "dev-master",
"dmhendricks/wordpress-toolkit": "0.3.0",
"dmhendricks/wordpress-toolkit": "dev-master",
"inc2734/wp-customizer-framework": "^2.3",
"composer/installers": "^1.5"
},
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"php": "5.6",
"carbon_fields": "2.2.0",
"wordpress-toolkit": "0.3.0"
"wordpress-toolkit": "0.3.1"
},
"network": {
"default_options_container": "global_settings"
Expand Down
3 changes: 1 addition & 2 deletions wordpress-base-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: WordPress Base Plugin
* Plugin URI: https://github.com/dmhendricks/wordpress-base-plugin
* Description: A boilerplate for WordPress plugins
* Version: 0.5.1
* Version: 0.5.2
* Author: Daniel M. Hendricks
* Author URI: https://www.danhendricks.com
* License: GPL-2.0
Expand Down Expand Up @@ -34,7 +34,6 @@
if( !defined( 'ABSPATH' ) ) die();

require( __DIR__ . '/vendor/autoload.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

// Initialize plugin
new \VendorName\PluginName\Plugin();

0 comments on commit fc0cab4

Please sign in to comment.