Skip to content

Commit

Permalink
able to change the banner img and the created year
Browse files Browse the repository at this point in the history
  • Loading branch information
lhy0807 committed Feb 15, 2016
1 parent c5c9200 commit 8e0ea0e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 300 deletions.
6 changes: 5 additions & 1 deletion footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
<div class="right" style="color: #000000;">
Theme By <a href="http://lhy.xyz" style="color: #F44336;">Chris Li</a>
&nbsp;&nbsp;
© 2014-<?php echo date("Y")?>
© <?php echo get_option('mad')['start_year']?>-<?php echo date("Y")?>
&nbsp;&nbsp;
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
</a>
</div>
</div>
</nav>
Expand Down
13 changes: 10 additions & 3 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@
<link href="<?php echo bloginfo('stylesheet_url');?>" type="text/css" rel="stylesheet" media="screen,projection"/>
<?php wp_head();?>
<?php
$banner_img = get_option('mad')['banner_img'];
if (!empty($banner_img)&&$banner_img!=="") {
$imgurl = $banner_img;
}
else {
$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
if(preg_match("/<url>(.+?)<\/url>/ies",$str,$matches)){
$imgurl='http://cn.bing.com'.$matches[1];
if(strstr($imgurl,'1366x768')) {
$imgurl = @str_replace('1366x768', '1920x1080', $imgurl);
}}
if(strstr($imgurl,'1366x768')) {
$imgurl = @str_replace('1366x768', '1920x1080', $imgurl);
}
}
}
?>
<script>
window.onload = function(){
Expand Down
8 changes: 4 additions & 4 deletions inc/includes/class-options-framework-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ static function menu_settings() {
'mode' => 'submenu',

// Submenu default settings
'page_title' => __( 'Theme Options', 'theme-textdomain' ),
'menu_title' => __( 'Theme Options', 'theme-textdomain' ),
'page_title' => __( '主题设置', 'theme-textdomain' ),
'menu_title' => __( '主题设置', 'theme-textdomain' ),
'capability' => 'edit_theme_options',
'menu_slug' => 'options-framework',
'parent_slug' => 'themes.php',
Expand Down Expand Up @@ -200,8 +200,8 @@ function options_page() { ?>
<?php settings_fields( 'optionsframework' ); ?>
<?php Options_Framework_Interface::optionsframework_fields(); /* Settings */ ?>
<div id="optionsframework-submit">
<input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'theme-textdomain' ); ?>" />
<input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'theme-textdomain' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'theme-textdomain' ) ); ?>' );" />
<input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( '保存设置', 'theme-textdomain' ); ?>" />
<input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( '恢复默认', 'theme-textdomain' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'theme-textdomain' ) ); ?>' );" />
<div class="clear"></div>
</div>
</form>
Expand Down
301 changes: 11 additions & 290 deletions options.php
Original file line number Diff line number Diff line change
@@ -1,314 +1,35 @@
<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
*/

function optionsframework_option_name() {
// Change this to use your theme slug
return 'mad';
}

/**
* Defines an array of options that will be used to generate the settings page and be saved in the database.
* When creating the 'id' fields, make sure to use all lowercase and no spaces.
*
* If you are making your theme translatable, you should replace 'theme-textdomain'
* with the actual text domain for your theme. Read more:
* http://codex.wordpress.org/Function_Reference/load_theme_textdomain
*/

function optionsframework_options() {

// Test data
$test_array = array(
'one' => __( 'One', 'theme-textdomain' ),
'two' => __( 'Two', 'theme-textdomain' ),
'three' => __( 'Three', 'theme-textdomain' ),
'four' => __( 'Four', 'theme-textdomain' ),
'five' => __( 'Five', 'theme-textdomain' )
);

// Multicheck Array
$multicheck_array = array(
'one' => __( 'French Toast', 'theme-textdomain' ),
'two' => __( 'Pancake', 'theme-textdomain' ),
'three' => __( 'Omelette', 'theme-textdomain' ),
'four' => __( 'Crepe', 'theme-textdomain' ),
'five' => __( 'Waffle', 'theme-textdomain' )
);

// 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', 'theme-textdomain' ),
'name' => __( '基础设置'),
'type' => 'heading'
);

$options[] = array(
'name' => __( 'Input Text Mini', 'theme-textdomain' ),
'desc' => __( 'A mini text input field.', 'theme-textdomain' ),
'id' => 'example_text_mini',
'std' => 'Default',
'name' => __( '站点起始年份'),
'desc' => __( '显示在页脚和归档页面'),
'id' => 'start_year',
'std' => '2014',
'class' => 'mini',
'type' => 'text'
);

$options[] = array(
'name' => __( 'Input Text', 'theme-textdomain' ),
'desc' => __( 'A text input field.', 'theme-textdomain' ),
'id' => 'example_text',
'std' => 'Default Value',
'type' => 'text'
);

$options[] = array(
'name' => __( 'Input with Placeholder', 'theme-textdomain' ),
'desc' => __( 'A text input field with an HTML5 placeholder.', 'theme-textdomain' ),
'id' => 'example_placeholder',
'placeholder' => 'Placeholder',
'type' => 'text'
);

$options[] = array(
'name' => __( 'Textarea', 'theme-textdomain' ),
'desc' => __( 'Textarea description.', 'theme-textdomain' ),
'id' => 'example_textarea',
'std' => 'Default Text',
'type' => 'textarea'
);

$options[] = array(
'name' => __( 'Input Select Small', 'theme-textdomain' ),
'desc' => __( 'Small Select Box.', 'theme-textdomain' ),
'id' => 'example_select',
'std' => 'three',
'type' => 'select',
'class' => 'mini', //mini, tiny, small
'options' => $test_array
);

$options[] = array(
'name' => __( 'Input Select Wide', 'theme-textdomain' ),
'desc' => __( 'A wider select box.', 'theme-textdomain' ),
'id' => 'example_select_wide',
'std' => 'two',
'type' => 'select',
'options' => $test_array
);

if ( $options_categories ) {
$options[] = array(
'name' => __( 'Select a Category', 'theme-textdomain' ),
'desc' => __( 'Passed an array of categories with cat_ID and cat_name', 'theme-textdomain' ),
'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', 'theme-textdomain' ),
'desc' => __( 'Passed an pages with ID and post_title', 'theme-textdomain' ),
'id' => 'example_select_pages',
'type' => 'select',
'options' => $options_pages
);

$options[] = array(
'name' => __( 'Input Radio (one)', 'theme-textdomain' ),
'desc' => __( 'Radio select with default options "one".', 'theme-textdomain' ),
'id' => 'example_radio',
'std' => 'one',
'type' => 'radio',
'options' => $test_array
);

$options[] = array(
'name' => __( 'Example Info', 'theme-textdomain' ),
'desc' => __( 'This is just some example information you can put in the panel.', 'theme-textdomain' ),
'type' => 'info'
);

$options[] = array(
'name' => __( 'Input Checkbox', 'theme-textdomain' ),
'desc' => __( 'Example checkbox, defaults to true.', 'theme-textdomain' ),
'id' => 'example_checkbox',
'std' => '1',
'type' => 'checkbox'
);

$options[] = array(
'name' => __( 'Advanced Settings', 'theme-textdomain' ),
'type' => 'heading'
);

$options[] = array(
'name' => __( 'Check to Show a Hidden Text Input', 'theme-textdomain' ),
'desc' => __( 'Click here and see what happens.', 'theme-textdomain' ),
'id' => 'example_showhidden',
'type' => 'checkbox'
);

$options[] = array(
'name' => __( 'Hidden Text Input', 'theme-textdomain' ),
'desc' => __( 'This option is hidden unless activated by a checkbox click.', 'theme-textdomain' ),
'id' => 'example_text_hidden',
'std' => 'Hello',
'class' => 'hidden',
'type' => 'text'
);

$options[] = array(
'name' => __( 'Uploader Test', 'theme-textdomain' ),
'desc' => __( 'This creates a full size uploader that previews the image.', 'theme-textdomain' ),
'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', 'theme-textdomain' ),
'desc' => __( 'Change the background CSS.', 'theme-textdomain' ),
'id' => 'example_background',
'std' => $background_defaults,
'type' => 'background'
);

$options[] = array(
'name' => __( 'Multicheck', 'theme-textdomain' ),
'desc' => __( 'Multicheck description.', 'theme-textdomain' ),
'id' => 'example_multicheck',
'std' => $multicheck_defaults, // These items get checked by default
'type' => 'multicheck',
'options' => $multicheck_array
);

$options[] = array(
'name' => __( 'Colorpicker', 'theme-textdomain' ),
'desc' => __( 'No color selected by default.', 'theme-textdomain' ),
'id' => 'example_colorpicker',
'name' => __( '站点Banner图片'),
'desc' => __( '留空即为显示Bing每日一图'),
'id' => 'banner_img',
'std' => '',
'type' => 'color'
);

$options[] = array( 'name' => __( 'Typography', 'theme-textdomain' ),
'desc' => __( 'Example typography.', 'theme-textdomain' ),
'id' => "example_typography",
'std' => $typography_defaults,
'type' => 'typography'
);

$options[] = array(
'name' => __( 'Custom Typography', 'theme-textdomain' ),
'desc' => __( 'Custom typography options.', 'theme-textdomain' ),
'id' => "custom_typography",
'std' => $typography_defaults,
'type' => 'typography',
'options' => $typography_options
);

$options[] = array(
'name' => __( 'Text Editor', 'theme-textdomain' ),
'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, // Default
'textarea_rows' => 5,
'tinymce' => array( 'plugins' => 'wordpress,wplink' )
);

$options[] = array(
'name' => __( 'Default Text Editor', 'theme-textdomain' ),
'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>', 'theme-textdomain' ), 'http://codex.wordpress.org/Function_Reference/wp_editor' ),
'id' => 'example_editor',
'type' => 'editor',
'settings' => $wp_editor_settings
'type' => 'text'
);

return $options;
}
6 changes: 6 additions & 0 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<img class="responsive-img" src="http://qr.topscan.com/api.php?text=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>"/>
</div>
<div class="modal-footer">
<div style="text-align: center;">
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
<img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
</a><br />
本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可。
</div>
<a href="#!" class=" modal-action modal-close waves-effect waves-blue btn-flat">关闭</a>
</div>
</div>
Expand Down
Loading

0 comments on commit 8e0ea0e

Please sign in to comment.