
Viewing 1 post (of 1 total)
-
AuthorPosts
-
October 10, 2025 at 1:59 pm #1490020
I have a custom shortcode:
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly if ( ! class_exists( 'avia_sc_portfolio_kacheln' ) ) { class avia_sc_portfolio_kacheln extends aviaShortcodeTemplate { /** * Create the config array for the shortcode button */ function shortcode_insert_button() { $this->config['version'] = '1.0'; $this->config['self_closing'] = 'no'; $this->config['base_element'] = 'yes'; $this->config['name'] = 'Portfolio Kachel'; $this->config['tab'] = 'wuk Elements'; $this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-image.png'; $this->config['order'] = 1; $this->config['target'] = 'avia-target-insert'; $this->config['shortcode'] = 'av_portfoliokachel'; // $this->config['modal_data'] = array( 'modal_class' => 'mediumscreen' ); $this->config['tooltip'] = __( 'Inserts an image of your choice', 'avia_framework' ); $this->config['preview'] = 1; $this->config['disabling_allowed'] = true; $this->config['id_name'] = 'id'; $this->config['id_show'] = 'yes'; } function popup_elements() { $template_url = get_stylesheet_directory_uri(); $this->elements = array( array( 'type' => 'tab_container', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Kachel', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'toggle_container', 'nodescription' => true ), array( "name" => __("Choose Image",'avia_framework' ), "desc" => __("Either upload a new, or choose an existing image from your media library",'avia_framework' ), "id" => "bild", "type" => "image", "title" => __("Insert Image",'avia_framework' ), "button" => __("Insert",'avia_framework' ), "std" => "", ), array( "name" => __("Title", 'avia_framework' ), "id" => "title", "std" => "", "type" => "input" ), array( "name" => __("Text", 'avia_framework' ), "id" => "text", "std" => "", "type" => "textarea" ), array( "name" => __("Button Text", 'avia_framework' ), "id" => "button_text", "std" => "", "type" => "input" ), array( 'name' => __( 'Image Link?', 'avia_framework' ), 'desc' => __( 'Where should your image link to?', 'avia_framework' ), 'id' => 'link', 'type' => 'linkpicker', 'fetchTMPL' => true, 'std' => '', 'lockable' => true, 'subtype' => array( __( 'No Link', 'avia_framework' ) => '', __( 'Lightbox', 'avia_framework' ) => 'lightbox', __( 'Set Manually', 'avia_framework' ) => 'manually', __( 'Single Entry', 'avia_framework' ) => 'single', __( 'Taxonomy Overview Page', 'avia_framework' ) => 'taxonomy', ) ), array( 'name' => __( 'Open new tab/window', 'avia_framework' ), 'desc' => __( 'Do you want to open the link url in a new tab/window?', 'avia_framework' ), 'id' => 'target', 'type' => 'select', 'std' => '', 'lockable' => true, 'required' => array( 'link', 'not_empty_and', 'lightbox' ), 'subtype' => AviaHtmlHelper::linking_options() ), array( 'type' => 'toggle_container_close', 'nodescription' => true ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Advanced', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'toggle_container', 'nodescription' => true ), array( 'type' => 'template', 'template_id' => 'screen_options_toggle', 'lockable' => true ), array( 'type' => 'template', 'template_id' => 'developer_options_toggle', 'args' => array( 'sc' => $this ) ), array( 'type' => 'toggle_container_close', 'nodescription' => true ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'template', 'template_id' => 'element_template_selection_tab', 'args' => array( 'sc' => $this ) ), array( 'type' => 'tab_container_close', 'nodescription' => true ), array( 'id' => 'av_element_hidden_in_editor', 'type' => 'hidden', 'std' => '0' ) ); } /** * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className * * * @param array $params this array holds the default values for $content and $args. * @return $params the return array usually holds an innerHtml key that holds item specific markup. */ function editor_element( $params ) { extract( $params['args'] ); global $KACHELINDEX; $KACHELINDEX++; if (strstr($link,"manually,")) { $url = str_replace("manually,","",$link); } elseif (strstr($link,",")) { $tmp = explode(",",$link); $url = get_the_permalink($tmp[1]); } $out = '<div class="portfolio_kacheln sameheight"'.((empty($button_text) && !empty($link)) ? ' onclick="location.href='.$url.'"' : '').'> <div class="bg2">'.str_pad($KACHELINDEX, 2, "0", STR_PAD_LEFT).'</div> <div class="pic" style="">'. '<img src="'.$bild.'" />'. '<h3>'.$title.'</h3>'. '</div>'. (!empty($text) ? '<p>'.$text.'</p>' : ''). ((!empty($link) && !empty($button_text)) ? '<p class="action"><a href="'.$url.'" class="button">'.$button_text.'</a></p>' : ''). '</div>'; $params['innerHtml'] = $out; return $params; } /** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @return string $output returns the modified html string */ function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' ) { extract( $atts ); global $KACHELINDEX; $KACHELINDEX++; if (strstr($link,"manually,")) { $url = str_replace("manually,","",$link); } elseif (strstr($link,",")) { $tmp = explode(",",$link); $url = get_the_permalink($tmp[1]); } $out = '<div class="portfolio_kacheln sameheight"'.((empty($button_text) && !empty($link)) ? ' onclick="'.($target == '' ? 'location.href='.$url.'"' : 'window.open(\''.$url.'\', \'_blank\');') : '').'> <div class="bg2">'.str_pad($KACHELINDEX, 2, "0", STR_PAD_LEFT).'</div> <div class="pic" style="">'. '<img src="'.$bild.'" />'. '<h3>'.$title.'</h3>'. '</div>'. (!empty($text) ? '<p>'.$text.'</p>' : ''). ((!empty($link) && !empty($button_text)) ? '<p class="action"><a'.($target != '' ? ' target="'.$target.'"' : '').' href="'.$url.'" class="button">'.$button_text.'</a></p>' : ''). '</div>'; return $out; } } }
taht generates a shortcode like:
[av_portfoliokachel bild='https://xexadeti.cyon.site/wp-content/uploads/2025/08/sta-schweisstechnische-ausbildung-mag-schweissen.jpg' attachment='277' attachment_size='full' title='MAG' text='(135 - Metall-Aktivgas-Schweissen) Unverändert: [av_portfoliokachel bild='https://xexadeti.cyon.site/wp-content/uploads/2025/08/sta-schweisstechnische-ausbildung-mag-schweissen.jpg' attachment='277' attachment_size='full' title='MAG' text='(135 - Metall-Aktivgas-Schweissen) Gelöscht: MAG – das Arbeitstier unter den Schweissverfahren! Wir zeigen dir, wie’s richtig geht!' button_text='Infos zu MAG' link='portfolio_entries,5' target='' id='' custom_class='' template_class='' av_element_hidden_in_editor='0' av_uid='av-mebf8h83' sc_version='1.0' admin_preview_bg=''][/av_portfoliokachel]
everything working fine, except oine thing, the ‘ Character.
array( "name" => __("Text", 'avia_framework' ), "id" => "text", "std" => "", "type" => "textarea" ),
If I enter a ‘ char in this “Text” field, it doesnt get escaped as it should
as example: text=’test’s’ will be the endresult and not text=’test\’s’. Is there a hook or filter where I can “correctly apply escaping to a field?Strangly, I did setup the page and that did work. I did update to latest enfold version and now, that is not working anymore. Is that a new bug that the encoding is not correctly working?
It dows work, when changing the field name from “text” to “content”. But what, if I want more than 1 “content” field?
Normal textarea should equallless its name escaped correctly in enfold…Thanks for aour advice or fix.
-
AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.