如何在略微修改的选项框架中添加样式表选择选项

时间:2013-12-12 01:04:31

标签: wordpress

我无法添加将添加选项的功能,我可以在其中选择样式表。

假设我有3个样式表(red.css,blue.css和green.css)。现在我想在SMOF中添加一个函数,我可以选择样式表,我的WordPress站点的设计将根据样式表进行更改。

我的代码如下 -

//Stylesheets Reader
        $alt_stylesheet_path = LAYOUT_PATH;
        $alt_stylesheets = array();

        if ( is_dir($alt_stylesheet_path) )
        {
            if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) )
            {
                while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false )
                {
                    if(stristr($alt_stylesheet_file, ".css") !== false)
                    {
                        $alt_stylesheets[] = $alt_stylesheet_file;
                    }
                }
            }
        }

$of_options_select  = array("option 1","option 2","option 3");              
$of_options[] = array(  "name"      => "Logo Uploader",
                        "desc"      => "Upload logo",
                        "id"        => "logo",
                        "std"       => "three",
                        "type"      => "select",
                        "options"   => $of_options_select
                );

任何人都请帮助我。我想在我的WordPress主题中选择这些函数。

1 个答案:

答案 0 :(得分:0)

您需要在主题中获得这些选项 这是您可以在wordpress主题中找到如何使用这些选项的链接 http://aquagraphite.com/2011/11/smof-documentation/

实施例: 要在选项面板中添加的新输入文本字段 id(属性)应该是唯一的,因为您将通过此ID访问您的数据。

$of_options[] = array(  "name"      => "Site Title",
                        "desc"      => "",
                        "id"        => "ams_site_title",
                        "std"       => "My Site",
                        "type"      => "text"
                );

通过全局化$ data数组并使用您的输入ID来访问主题文件中的数据。

global $data; //fetch options stored in $data
echo $data['ams_site_title'];

那就是它。