Ejemplo n.º 1
0
function cmsblue_shortcode_template($settings, $value)
{
    $shortcode = $settings['shortcode'];
    $theme_dir = get_template_directory() . '/vc_templates';
    $reg = "/^({$shortcode}\\.php|{$shortcode}--.*\\.php)/";
    $files = cmsblueFileScanDirectory($theme_dir, $reg);
    $files = array_merge(cmsblueFileScanDirectory(CMSBLUE_TEMPLATES, $reg), $files);
    $output = "";
    $output .= "<select name=\"" . esc_attr($settings['param_name']) . "\" class=\"wpb_vc_param_value\">";
    foreach ($files as $key => $file) {
        if ($key == esc_attr($value)) {
            $output .= "<option value=\"{$key}\" selected>{$key}</option>";
        } else {
            $output .= "<option value=\"{$key}\">{$key}</option>";
        }
    }
    $output .= "</select>";
    $script = <<<SCRIPT
    <script type="text/javascript">
        jQuery('button.vc_panel-btn-save[data-save=true]').click(function(){
            jQuery('.cms_custom_param.vc_dependent-hidden').remove();
        });
    </script>
SCRIPT;
    return $output . $script;
}
Ejemplo n.º 2
0
function cmsblueFileScanDirectory($dir, $mask, $options = array(), $depth = 0)
{
    $options += array('nomask' => '/(\\.\\.?|CSV)$/', 'callback' => 0, 'recurse' => TRUE, 'key' => 'uri', 'min_depth' => 0);
    $options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
    $files = array();
    if (is_dir($dir) && ($handle = opendir($dir))) {
        while (FALSE !== ($filename = readdir($handle))) {
            if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') {
                $uri = "{$dir}/{$filename}";
                if (is_dir($uri) && $options['recurse']) {
                    // Give priority to files in this folder by merging them in after any subdirectory files.
                    $files = array_merge(cmsblueFileScanDirectory($uri, $mask, $options, $depth + 1), $files);
                } elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
                    // Always use this match over anything already set in $files with the
                    // same $$options['key'].
                    $file = new stdClass();
                    $file->uri = $uri;
                    $file->filename = $filename;
                    $file->name = pathinfo($filename, PATHINFO_FILENAME);
                    $files[$filename] = $file;
                }
            }
        }
        closedir($handle);
    }
    return $files;
}
Ejemplo n.º 3
0
 protected function findShortcodeTemplates()
 {
     $theme_dir = get_template_directory() . '/vc_templates';
     $reg = "/^({$this->shortcode}\\.php|{$this->shortcode}--.*\\.php)/";
     $files = cmsblueFileScanDirectory($theme_dir, $reg);
     $files = array_merge(cmsblueFileScanDirectory(CMSBLUE_TEMPLATES, $reg), $files);
     return $files;
 }