From 9b7097e4da9c3c3e24d26e5f805325ea1e6ce261 Mon Sep 17 00:00:00 2001 From: Ervin Domonkos Date: Wed, 3 Jul 2019 16:05:33 +0200 Subject: [PATCH] Tweak to make the FW code usable earlier in the line, 2019-07-03 --- README.md | 4 ++++ framework/data-types/type-number.php | 3 --- framework/tpl-fw.php | 26 +++++++++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 67ced67..4214583 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Documentation will be available soon. ## Changelog +### v1.3.4 (2019-07-03) +* Made it possible to run the FW code earlier in the hooks + + ### v1.3.3 (2019-04-17) * TinyMCE double button line bugfix diff --git a/framework/data-types/type-number.php b/framework/data-types/type-number.php index 24b03e3..d18b6d2 100644 --- a/framework/data-types/type-number.php +++ b/framework/data-types/type-number.php @@ -13,9 +13,6 @@ class TPL_Number extends TPL_Data_Type { // Writes the form field in wp-admin public function form_field_content ( $args ) { - // var_dump($this); - // var_dump($this->get_option()); - if ( $this->get_option() === NULL ) { $value = $this->default; } diff --git a/framework/tpl-fw.php b/framework/tpl-fw.php index aa567c8..089eee4 100755 --- a/framework/tpl-fw.php +++ b/framework/tpl-fw.php @@ -8,19 +8,19 @@ // Version number of the framework -define( 'TPL_VERSION', '1.3.3' ); +define( 'TPL_VERSION', '1.3.4' ); // Firstly, adding the necessary action hooks -// Adding admin script... -add_action ( 'admin_enqueue_scripts', 'tpl_admin_scripts', 20 ); +// Load data type components +tpl_load_data_types(); -// Load data type components -add_action ( 'init', 'tpl_load_data_types' ); +// Adding admin script... +add_action ( 'admin_enqueue_scripts', 'tpl_admin_scripts', 20 ); // Initial actions (menus, admin pages) @@ -165,6 +165,7 @@ function tpl_load_data_types () { "type-page_builder", ); + // Now run the load loop for Data Types foreach ( $files as $file ) { @@ -258,11 +259,22 @@ function tpl_remove_empty_p ( $content ) { OPTION HANDLING */ + +// Registers a setting page +function tpl_add_settings_page( $name, $settings_page_array ) { + global $tpl_settings_pages; + + $tpl_settings_pages[$name] = $settings_page_array; + +} + + + // Register an option in the framework function tpl_register_option ( $narr ) { // Use the global $tpl_options_array that builds up the Plugin Settings panel - global $tpl_options_array, $tpl_data_types; + global $tpl_options_array; $narr = apply_filters( 'tpl_before_register_option', $narr ); @@ -284,7 +296,7 @@ function tpl_register_option ( $narr ) { // If not registered yet, register it if ( !$already_registered ) { - if ( !isset( $narr["type"] ) || !in_array( $narr["type"], $tpl_data_types ) ) { + if ( !isset( $narr["type"] ) || !tpl_type_registered( $narr["type"] ) ) { tpl_error( sprintf(