示例#1
0
文件: titles.php 项目: ycms/framework
Func::make("cutlass_title", function () {
    /**
     * @param string $title
     * @return null|string|void
     */
    function cutlass_title($title = '')
    {
        if ($title) {
            return __($title);
        }
        if (is_home()) {
            if (get_option('page_for_posts', true)) {
                return get_the_title(get_option('page_for_posts', true));
            } else {
                return __('Latest Posts', 'cutlass');
            }
        } elseif (is_archive()) {
            $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
            if ($term) {
                return apply_filters('single_term_title', $term->name);
            } elseif (is_post_type_archive()) {
                return apply_filters('the_title', get_queried_object()->labels->name);
            } elseif (is_day()) {
                return sprintf(__('Daily Archives: %s', 'cutlass'), get_the_date());
            } elseif (is_month()) {
                return sprintf(__('Monthly Archives: %s', 'cutlass'), get_the_date('F Y'));
            } elseif (is_year()) {
                return sprintf(__('Yearly Archives: %s', 'cutlass'), get_the_date('Y'));
            } elseif (is_author()) {
                $author = get_queried_object();
                return sprintf(__('Author Archives: %s', 'cutlass'), apply_filters('the_author', is_object($author) ? $author->display_name : null));
            } else {
                return single_cat_title('', false);
            }
        } elseif (is_search()) {
            return sprintf(__('Search Results for %s', 'cutlass'), get_search_query());
        } elseif (is_404()) {
            return __('Not Found', 'cutlass');
        } else {
            return get_the_title();
        }
    }
});
示例#2
0
Func::make('optionsframework_options', function () {
    function optionsframework_options()
    {
        $sliders_array = array("none" => "None", "flex" => "Flex Slider");
        $slidersfx_array = array("fade" => "fade", "slide" => "slide");
        $sliders = get_categories('taxonomy=sliders&type=featured');
        $sliders_tags_array[''] = 'Select a Slider';
        foreach ($sliders as $slider) {
            $sliders_tags_array[$slider->cat_ID] = $slider->cat_name;
        }
        $numberofs_array = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "11" => "11", "12" => "12", "13" => "13", "14" => "14", "15" => "15", "16" => "16", "17" => "17", "18" => "18", "19" => "19", "20" => "20");
        $robots_array = array("none" => "none", "index,follow" => "index,follow", "index, follow" => "index, follow", "index,nofollow" => "index,nofollow", "index,all" => "index,all", "index,follow,archive" => "index,follow,archive", "noindex,follow" => "noindex,follow", "noindex,nofollow" => "noindex,nofollow");
        // Background Defaults
        $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll');
        // Pull all the categories into an array
        $options_categories = array();
        $options_categories_obj = get_categories();
        $options_categories[''] = __('All Categories', 'site5framework');
        foreach ($options_categories_obj as $category) {
            $options_categories[$category->cat_ID] = $category->cat_name;
        }
        // Pull all the pages into an array
        $options_pages = array();
        $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
        $options_pages[''] = __('Select a page:', 'site5framework');
        foreach ($options_pages_obj as $page) {
            $options_pages[$page->ID] = $page->post_title;
        }
        $options = array();
        /*********************************************************************************************
         *
         * Initalize Theme Options
         *********************************************************************************************/
        if (!function_exists('optionsframeworks_init')) {
            require OPTIONS_DIRECTORY . 'general.php';
            require OPTIONS_DIRECTORY . 'typography.php';
            require OPTIONS_DIRECTORY . 'slider.php';
            require OPTIONS_DIRECTORY . 'portfolio.php';
            require OPTIONS_DIRECTORY . 'blog.php';
            require OPTIONS_DIRECTORY . 'contact.php';
            require OPTIONS_DIRECTORY . 'social.php';
            require OPTIONS_DIRECTORY . 'meta.php';
            require OPTIONS_DIRECTORY . 'footer.php';
            require OPTIONS_DIRECTORY . 'thumbnails.php';
        }
        return $options;
    }
});
示例#3
0
文件: option.php 项目: ycms/framework
Func::make('optionsframework_options', function () {
    function optionsframework_options()
    {
        // Test data
        $test_array = array('one' => __('One', 'default'), 'two' => __('Two', 'default'), 'three' => __('Three', 'default'), 'four' => __('Four', 'default'), 'five' => __('Five', 'default'));
        // Multicheck Array
        $multicheck_array = array('one' => __('French Toast', 'default'), 'two' => __('Pancake', 'default'), 'three' => __('Omelette', 'default'), 'four' => __('Crepe', 'default'), 'five' => __('Waffle', 'default'));
        // Multicheck Defaults
        $multicheck_defaults = array('one' => '1', 'five' => '1');
        // Background Defaults
        $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll');
        // Typography Defaults
        $typography_defaults = array('size' => '15px', 'face' => 'georgia', 'style' => 'bold', 'color' => '#bada55');
        // Typography Options
        $typography_options = array('sizes' => array('6', '12', '14', '16', '20'), 'faces' => array('Helvetica Neue' => 'Helvetica Neue', 'Arial' => 'Arial'), 'styles' => array('normal' => 'Normal', 'bold' => 'Bold'), 'color' => false);
        // Pull all the categories into an array
        $options_categories = array();
        $options_categories_obj = get_categories();
        foreach ($options_categories_obj as $category) {
            $options_categories[$category->cat_ID] = $category->cat_name;
        }
        // Pull all tags into an array
        $options_tags = array();
        $options_tags_obj = get_tags();
        foreach ($options_tags_obj as $tag) {
            $options_tags[$tag->term_id] = $tag->name;
        }
        // Pull all the pages into an array
        $options_pages = array();
        $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
        $options_pages[''] = 'Select a page:';
        foreach ($options_pages_obj as $page) {
            $options_pages[$page->ID] = $page->post_title;
        }
        // If using image radio buttons, define a directory path
        $imagepath = get_template_directory_uri() . '/images/';
        $options = array();
        $options[] = array('name' => __('Basic Settings', 'default'), 'type' => 'heading');
        $options[] = array('name' => __('Input Text Mini', 'default'), 'desc' => __('A mini text input field.', 'default'), 'id' => 'example_text_mini', 'std' => 'Default', 'class' => 'mini', 'type' => 'text');
        $options[] = array('name' => __('Input Text', 'default'), 'desc' => __('A text input field.', 'default'), 'id' => 'example_text', 'std' => 'Default Value', 'type' => 'text');
        $options[] = array('name' => __('Input with Placeholder', 'default'), 'desc' => __('A text input field with an HTML5 placeholder.', 'default'), 'id' => 'example_placeholder', 'placeholder' => 'Placeholder', 'type' => 'text');
        $options[] = array('name' => __('Textarea', 'default'), 'desc' => __('Textarea description.', 'default'), 'id' => 'example_textarea', 'std' => 'Default Text', 'type' => 'textarea');
        $options[] = array('name' => __('Input Select Small', 'default'), 'desc' => __('Small Select Box.', 'default'), 'id' => 'example_select', 'std' => 'three', 'type' => 'select', 'class' => 'mini', 'options' => $test_array);
        $options[] = array('name' => __('Input Select Wide', 'default'), 'desc' => __('A wider select box.', 'default'), 'id' => 'example_select_wide', 'std' => 'two', 'type' => 'select', 'options' => $test_array);
        if ($options_categories) {
            $options[] = array('name' => __('Select a Category', 'default'), 'desc' => __('Passed an array of categories with cat_ID and cat_name', 'default'), 'id' => 'example_select_categories', 'type' => 'select', 'options' => $options_categories);
        }
        if ($options_tags) {
            $options[] = array('name' => __('Select a Tag', 'options_check'), 'desc' => __('Passed an array of tags with term_id and term_name', 'options_check'), 'id' => 'example_select_tags', 'type' => 'select', 'options' => $options_tags);
        }
        $options[] = array('name' => __('Select a Page', 'default'), 'desc' => __('Passed an pages with ID and post_title', 'default'), 'id' => 'example_select_pages', 'type' => 'select', 'options' => $options_pages);
        $options[] = array('name' => __('Input Radio (one)', 'default'), 'desc' => __('Radio select with default options "one".', 'default'), 'id' => 'example_radio', 'std' => 'one', 'type' => 'radio', 'options' => $test_array);
        $options[] = array('name' => __('Example Info', 'default'), 'desc' => __('This is just some example information you can put in the panel.', 'default'), 'type' => 'info');
        $options[] = array('name' => __('Input Checkbox', 'default'), 'desc' => __('Example checkbox, defaults to true.', 'default'), 'id' => 'example_checkbox', 'std' => '1', 'type' => 'checkbox');
        $options[] = array('name' => __('Advanced Settings', 'default'), 'type' => 'heading');
        $options[] = array('name' => __('Check to Show a Hidden Text Input', 'default'), 'desc' => __('Click here and see what happens.', 'default'), 'id' => 'example_showhidden', 'type' => 'checkbox');
        $options[] = array('name' => __('Hidden Text Input', 'default'), 'desc' => __('This option is hidden unless activated by a checkbox click.', 'default'), 'id' => 'example_text_hidden', 'std' => 'Hello', 'class' => 'hidden', 'type' => 'text');
        $options[] = array('name' => __('Uploader Test', 'default'), 'desc' => __('This creates a full size uploader that previews the image.', 'default'), 'id' => 'example_uploader', 'type' => 'upload');
        $options[] = array('name' => "Example Image Selector", 'desc' => "Images for layout.", 'id' => "example_images", 'std' => "2c-l-fixed", 'type' => "images", 'options' => array('1col-fixed' => $imagepath . '1col.png', '2c-l-fixed' => $imagepath . '2cl.png', '2c-r-fixed' => $imagepath . '2cr.png'));
        $options[] = array('name' => __('Example Background', 'default'), 'desc' => __('Change the background CSS.', 'default'), 'id' => 'example_background', 'std' => $background_defaults, 'type' => 'background');
        $options[] = array('name' => __('Multicheck', 'default'), 'desc' => __('Multicheck description.', 'default'), 'id' => 'example_multicheck', 'std' => $multicheck_defaults, 'type' => 'multicheck', 'options' => $multicheck_array);
        $options[] = array('name' => __('Colorpicker', 'default'), 'desc' => __('No color selected by default.', 'default'), 'id' => 'example_colorpicker', 'std' => '', 'type' => 'color');
        $options[] = array('name' => __('Typography', 'default'), 'desc' => __('Example typography.', 'default'), 'id' => "example_typography", 'std' => $typography_defaults, 'type' => 'typography');
        $options[] = array('name' => __('Custom Typography', 'default'), 'desc' => __('Custom typography options.', 'default'), 'id' => "custom_typography", 'std' => $typography_defaults, 'type' => 'typography', 'options' => $typography_options);
        $options[] = array('name' => __('Text Editor', 'default'), 'type' => 'heading');
        /**
         * For $settings options see:
         * http://codex.wordpress.org/Function_Reference/wp_editor
         * 'media_buttons' are not supported as there is no post to attach items to
         * 'textarea_name' is set by the 'id' you choose
         */
        $wp_editor_settings = array('wpautop' => true, 'textarea_rows' => 5, 'tinymce' => array('plugins' => 'wordpress'));
        $options[] = array('name' => __('Default Text Editor', 'default'), 'desc' => sprintf(__('You can also pass settings to the editor.  Read more about wp_editor in <a href="%1$s" target="_blank">the WordPress codex</a>', 'default'), 'http://codex.wordpress.org/Function_Reference/wp_editor'), 'id' => 'example_editor', 'type' => 'editor', 'settings' => $wp_editor_settings);
        return $options;
    }
});
示例#4
0
文件: utils.php 项目: ycms/theme-evo
<?php

use YCMS\Extensions\Func;
Func::make('is_element_empty', function () {
    /**
     * @param $element
     * @return bool
     */
    function is_element_empty($element)
    {
        $element = trim($element);
        return !empty($element);
    }
});
示例#5
0
                    //返回碎片
                    break;
                case 'thumb':
                    return $fragment->thumb;
                    //返回碎片缩略图地址
                    break;
                case 'title':
                    return $fragment->title;
                    //返回碎片标题
                    break;
                default:
                    return htmlspecialchars_decode($fragment->content);
                    //默认返回碎片内容
                    break;
            }
        }
    }
});
Func::make('asset', function () {
    /**
     * Generate an asset path for the application.
     *
     * @param  string $path
     * @param  bool   $secure
     * @return string
     */
    function asset($path, $secure = null)
    {
        return app('url')->asset('static/' . preg_replace("/^static\\//", '', $path), $secure);
    }
});