Пример #1
0
/**
 * Renders the "Customize" button.
 *
 * @access private
 * @since  8.4
 *
 * @param cnTemplate $template
 * @param string     $customizerURL
 * @param string     $returnURL
 */
function cnTemplateCustomizerButton($template, $customizerURL, $returnURL)
{
    if ($template->supports('customizer')) {
        $href = add_query_arg(array('url' => urlencode(add_query_arg('cn-template', $template->getSlug(), $customizerURL)), 'cn-template' => $template->getSlug(), 'return' => urlencode($returnURL)), 'customize.php');
        /**
         * NOTE: According to the docs for the JavaScript Customizer API, you can auto focus
         *       to the panel, section or control you wish via the URL. Which does work.
         *
         *       However, if you add this via @see add_query_arg() or escape it using
         *       @see esc_url() the required bracket will be removed which are required
         *       for auto focusing via the URL too function. This is why I added it after
         *       escaping the URL.
         *
         * @link https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/#focusing
         */
        ?>
		<a class="button"
		   href="<?php 
        echo esc_url($href) . '&autofocus[section]=cn_template_customizer_section_display';
        ?>
"
		   title="Customize '<?php 
        echo esc_attr($template->getName());
        ?>
'"><?php 
        _e('Customize', 'connections');
        ?>
</a>
		<?php 
    }
}
Пример #2
0
 /**
  * @param cnTemplate $template
  */
 public function __construct($template)
 {
     $this->template = $template;
     add_filter('cn_list_atts-' . $template->getSlug(), array(__CLASS__, 'initOptions'));
 }