Tagged: avf_sync_sc_defaults_array, enfoold, filter
-
AuthorPosts
-
January 3, 2025 at 10:40 am #1474516
See here https://kriesi.at/support/topic/metadata-element-possible-to-add-default-settings/
Its a filter to change the defaults.function custom_avf_sync_sc_defaults_array( $defaults, $sc_class, $is_modal_item, $content ) { if(get_class($sc_class) == "avia_sc_hr") { $log .= "Filter wurde aufgerufen\n"; $defaults['height'] = '30'; $defaults['class'] = 'invisible'; } return $defaults; } add_filter( 'avf_sync_sc_defaults_array', 'custom_avf_sync_sc_defaults_array', 10, 4 );
This code changes the detault HR hight to 30 and to invisible. And that does work when you check that the defaults get changed. But that doesnt affect anything at the end, as it seams the defaults get ignored, or with that particular element they are not working.
How chan I change the default values correctly that they are used?
Thanks
January 3, 2025 at 11:15 am #1474517I checked other filters:
add_filter('avf_in_shortcode_handler_prepare_start', function($args) { if ($args[4] == "av_hr") { $args[2]['class'] = "invisible"; $args[2]['height'] = '30'; } return $args; }, 10, 1);
also this filter edits the default values, without luck.
in parallel I edited directly the file enfold/config-templatebuilder/avia-shortcode/hr/hr.php :
*/ protected function register_dynamic_templates() { /** * Styling Tab * =========== */ $c = array( array( 'name' => __( 'Horizontal Ruler Styling', 'avia_framework' ), 'desc' => __( 'Here you can set the styling and size of the HR element', 'avia_framework' ), 'id' => 'class', 'type' => 'select', 'std' => 'default', 'lockable' => true, 'subtype' => array( __( 'Predefined Separators', 'avia_framework' ) => array( __( 'Default', 'avia_framework' ) => 'default', __( 'Big Top and Bottom Margins', 'avia_framework' ) => 'big', __( 'Fullwidth Separator', 'avia_framework' ) => 'full', __( 'Whitespace', 'avia_framework' ) => 'invisible', __( 'Short Separator', 'avia_framework' ) => 'short', ), __( 'Custom Separator', 'avia_framework' ) => array( __( 'Custom', 'avia_framework' ) => 'custom', ), ) ),
Changes in protected function register_dynamic_templates() , like a new default value working, but there is no filter which applies there te changes, except hardchaing in the files..
In this here I can also change directy the $default values:
protected function get_element_styles( array $args ) { $result = parent::get_element_styles( $args ); extract( $result ); $default = array( 'class' => 'invisible', 'height' => '50',
which sould do afterwards $default = $this->sync_sc_defaults_array( $default );
here the default values can be changed, but as they are already set as $atts, the $this->sync_sc_defaults_array( $default ); is never used. as $atts are set. :/
so default values can only be changed in hardcoded files. Please check that the filter is woking.
- This reply was modified 2 weeks, 1 day ago by BlutVampir.
January 3, 2025 at 12:21 pm #1474530i do not know why the filter does not work in this case – and even if you use it as in the github example:
function custom_avf_sync_sc_defaults_array( $defaults, $sc_class, $is_modal_item, $content ){ if( $sc_class instanceof avia_sc_hr ){ $defaults['height'] = '30'; $defaults['class'] = 'invisible'; } return $defaults; } add_filter( 'avf_sync_sc_defaults_array', 'custom_avf_sync_sc_defaults_array', 10, 4 );
it does not change the allready set default hr’s
you can change them to that value via css :
#top .hr.hr-default { height: 30px; } #top .hr.hr-default .hr-inner { border: none !important; }
January 3, 2025 at 1:02 pm #1474561I continued to search. I did found a dirty solution.
As mentioned earlier, I think these should work, but dont work:
add_filter( 'avf_sync_sc_defaults_array', function( $defaults, $sc_class, $is_modal_item, $content ) { if(get_class($sc_class) == "avia_sc_hr") { $defaults['height'] = '30'; $defaults['class'] = 'invisible'; } return $defaults; }, 30, 4 ); add_filter('avf_in_shortcode_handler_prepare_start', function($args) { if ($args[4] == "av_hr") { $args[2]['class'] = "invisible"; $args[2]['height'] = '30'; } return $args; }, 30, 1);
This filter is working:
add_filter('avf_template_builder_shortcode_elements', function($elements) { if ($_POST['action'] == 'avia_ajax_av_hr') { $incoming_shortcode = trim(stripslashes($_POST['params']['shortcode'])); $compare_shortcode = trim(stripslashes("[av_hr class='default' icon_select='yes' icon='ue808' position='center' shadow='no-shadow' height='50' custom_border='av-border-thin' custom_width='50px' custom_margin_top='30px' custom_margin_bottom='30px' custom_border_color='' custom_icon_color='' av-desktop-hide='' av-medium-hide='' av-small-hide='' av-mini-hide='' id='' custom_class='' template_class='' av_uid='' sc_version='1.0']")); if ($incoming_shortcode === $compare_shortcode) { $_POST['template_changed'] = true; $_POST['params']['shortcode'] = "[av_hr class='invisible' icon_select='yes' icon='ue808' position='center' shadow='no-shadow' height='30' custom_border='av-border-thin' custom_width='50px' custom_margin_top='30px' custom_margin_bottom='30px' custom_border_color='' custom_icon_color='' av-desktop-hide='' av-medium-hide='' av-small-hide='' av-mini-hide='' id='' custom_class='' template_class='' av_uid='' sc_version='1.0']"; } } return $elements; }, 15, 1);
I modify there the default shortcode and only if the shortcode is absolutly identical. as I change the height which is unused in the “standard” I can use standard when normally set, as then is 30 in the backend and the new values dont get applied. Very dirty and bad code, but didnt find any reasonable other way to do it.
January 3, 2025 at 1:11 pm #1474562i guess the reason for that changing of default values is that you like all default hr’s change to those new values – so the css solution did that job.
#top .hr.hr-default { height: 30px; } #top .hr.hr-default .hr-inner { border: none !important; }
but I also understand your desire to make it possible via that filter.
January 3, 2025 at 1:31 pm #1474563ok on github the filter has on top the comment: link
* Allows to modify the default shortcode values if an attribute is missing in shortcode. * This will not change set attributes in shortcode.
so it is clear now – but why then the separator could be set on that example?
-
AuthorPosts
- You must be logged in to reply to this topic.