Closed danyj closed 6 years ago
And with @ViorelEremia suggestion here #2848
global $wp_post_types;
'post_type' => array(
'type' => 'select',
'value' => '',
'attr' => array( 'class' => 'custom-class', 'data-foo' => 'bar' ),
'label' => __('Label', '{domain}'),
'desc' => __('Description', '{domain}'),
'help' => __('Help tip', '{domain}'),
'choices' => array_map( function( $post_type ) { return $post_type->labels->singular_name; }, $wp_post_types ),
/**
* Allow save not existing choices
* Useful when you use the select to populate it dynamically from js
*/
'no-validate' => false,
),
this is the print
as you see many PT are missing.
I tried with the core and it is working, the function current_filter() return hook appearance_page_fw-settings that hook is executed after hook init which usually in this hoook custom post types are registered.
please show me what you have tried and where ,
I am in theme options include file and it does not show all post types
Define global: global $wp_post_types;
'post_type' => array(
'type' => 'select',
'value' => '',
'attr' => array( 'class' => 'custom-class', 'data-foo' => 'bar' ),
'label' => __('Label ' . current_filter(), '{domain}'),
'desc' => __('Description', '{domain}'),
'help' => __('Help tip', '{domain}'),
'choices' => array_map( function( $post_type ) { return $post_type->labels->singular_name; }, $wp_post_types ),
/**
* Allow save not existing choices
* Useful when you use the select to populate it dynamically from js
*/
'no-validate' => false,
),
as I said before it does not work , pay close attention that portfolio is missing as well as any other CPT
do fw print in core e-core-parent\framework-customizations\theme\options/ settings.php
or theme requirements
I don't see any solution if you remove code from the-core/theme-includes/hooks.php:
if ( function_exists( 'fw_get_db_settings_option' ) ) {
$general_products_options = fw_get_db_settings_option( 'general_products_options', '' );
if ( fw_akg('product_gallery', $general_products_options) == 'slider' ) {
add_theme_support( 'wc-product-gallery-slider' );
}
else {
add_theme_support( 'wc-product-gallery-lightbox' );
}
if ( fw_akg('product_zoom', $general_products_options) == 'yes' ) {
add_theme_support( 'wc-product-gallery-zoom' );
}
}
else {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-zoom' );
}
You see that file settings.php is no more ccalled in hook after_setup_theme so if you use that function fw_get_db_settings_option
before hook init you can't get all registered custom post type.
what you want to do?
I am not trying to do anything I just need you to confirm that I am not going crazy and that the core theme is doing custom things .
so to recap the get_post_types does not list all within theme settings correct ?
I think is something with init.php , we were forced due to themeforest requirements to change the inti.php https://github.com/ThemeFuse/Unyson/issues/2431
and the one the-core is using passed but there is something inside that makes all posts types be visible, looks like inclusion order , I am digging ,
the scratch theme lists all types , even more than core on same install and I aded print in same file
When the theme options are shown the current hook is appearance_page_fw-settings it is executed after hook init so you have all registered custom post types but if you try to find all register post types when the first time the file settings.php is called you can't, because you're calling somewhere in your theme before the hook init how is in the-core exemple with function fw_get_db_settings_option called in hook after_setup_theme. You can find a solution but it depends on what you want to do for us it is working when option types are shown: https://github.com/ThemeFuse/Unyson/issues/3073#issuecomment-351066372 With scratch theme is working because file settings.php is not called anywhere before init hook.
give me an idea what you want to do and maybe I can help
s but if you try to find all register post types when the first time the file settings.php
that is what I tought but than I called the get_post_type
here
and that is the image you see above
so I am trying to figure out if I made a mistake in my theme includes or anything or something else is going on
give me an idea what you want to do and ma
what I need to do is get all available post types within a select , and I am doing that inside the $options array like you did with global var , but is not listing all for me
Check in yuour theme for function fw_get_db_settings_option is it called in a hook which runs before init This function include file settings in class _FW_Component_Theme function get_options so if you call it before hoook init you can't extract posttypes or is something else.
Check in yuour theme for function fw_get_db_settings_opt
ahh, forgot about that , must be , will check
add these in your settings.php:
if ( current_filter() == 'after_setup_theme' ) {
echo '<pre style="z-index:1000000;position:relative;color:#78FF5B;background:#23282d;">';
print_r( debug_backtrace( 0 ) );
echo '</pre>';
}
Array
(
[0] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\helpers\general.php
[line] => 770
[function] => require
)
[1] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\core\components\theme.php
[line] => 70
[function] => fw_get_variables_from_file
[args] => Array
(
[0] => T:\wamp64\www\Development\WordPress/wp-content/themes/creatus/inc/thzframework/theme/options/settings.php
[1] => Array
(
[options] => Array
(
)
)
)
)
[2] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\core\components\theme.php
[line] => 81
[function] => get_options
[class] => _FW_Component_Theme
[type] => ->
[args] => Array
(
[0] => settings
)
)
[3] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\helpers\database.php
[line] => 12
[function] => get_settings_options
[class] => _FW_Component_Theme
[type] => ->
[args] => Array
(
)
)
[4] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\helpers\class-fw-db-options-model.php
[line] => 176
[function] => get_options
[class] => FW_Db_Options_Model_Settings
[type] => ->
[args] => Array
(
[0] =>
[1] => Array
(
)
)
)
[5] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\plugins\unyson\framework\helpers\database.php
[line] => 65
[function] => get
[class] => FW_Db_Options_Model
[type] => ->
[args] => Array
(
[0] =>
[1] => presets
[2] =>
)
)
[6] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\themes\creatus\inc\helpers.php
[line] => 81
[function] => fw_get_db_settings_option
[args] => Array
(
[0] => presets
[1] =>
)
)
[7] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-content\themes\creatus\inc\hooks.php
[line] => 62
[function] => thz_get_theme_option
[args] => Array
(
[0] => presets
[1] =>
)
)
[8] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-includes\class-wp-hook.php
[line] => 286
[function] => _thz_action_theme_setup
[args] => Array
(
[0] =>
)
)
[9] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-includes\class-wp-hook.php
[line] => 310
[function] => apply_filters
[class] => WP_Hook
[type] => ->
[args] => Array
(
[0] =>
[1] => Array
(
[0] =>
)
)
)
[10] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-includes\plugin.php
[line] => 453
[function] => do_action
[class] => WP_Hook
[type] => ->
[args] => Array
(
[0] => Array
(
[0] =>
)
)
)
[11] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-settings.php
[line] => 434
[function] => do_action
[args] => Array
(
[0] => after_setup_theme
)
)
[12] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-config.php
[line] => 102
[args] => Array
(
[0] => T:\wamp64\www\Development\WordPress\wp-settings.php
)
[function] => require_once
)
[13] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-load.php
[line] => 37
[args] => Array
(
[0] => T:\wamp64\www\Development\WordPress\wp-config.php
)
[function] => require_once
)
[14] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-admin\admin.php
[line] => 31
[args] => Array
(
[0] => T:\wamp64\www\Development\WordPress\wp-load.php
)
[function] => require_once
)
[15] => Array
(
[file] => T:\wamp64\www\Development\WordPress\wp-admin\themes.php
[line] => 10
[args] => Array
(
[0] => T:\wamp64\www\Development\WordPress\wp-admin\admin.php
)
[function] => require_once
)
)
I cant find the issue , just deleted all hooks from hooks.php and still not getting anything
unbelievable ,
deleted ALL options from settings.php removed all custom options types removed ALL hooks ,
same thing
on same install scratch theme gets all PT
Check for each filter, add in your settings.php current_filter(). I can't inspect your code maybe is with this function or something else i can't say
wait , got it , DARN , one of include classes http://prntscr.com/hmijaa , digging further
Filters: after_setup_theme -> fw_before_init -> switch_blog -> fw_extensions_before_init -> fw_extensions_init -> fw_init -> fw_option_types_init -> fw_option_type_form_builder_init -> fw:option-storage-types:register -> init check for all these hooks until init or for custom hooks if you have
thnx for helping out , it is widgets_init , that is where I asked for a theme option , and that kills the post types
@ViorelEremia @andreiglingeanu
in any theme options file do
fw_print ( get_post_types() );
it returns only builtin post no CPT and not even the FW portfolio, but for some reason it sees events, I have a plugin registering post type and I am not getting it with this, also , if user registered his post type in functions.php you will not see this post type in theme settings,
however if you do a print in any option type class you do see the CPT
ref https://github.com/ThemeFuse/Unyson/issues/2848