├── .gitignore ├── 404.php ├── CHANGELOG.md ├── LICENSE ├── README.md ├── author.php ├── footer.php ├── functions.php ├── header.php ├── images ├── jetbrains.svg └── post.jpg ├── inc ├── Utils.php ├── css │ ├── optionsframework.css │ └── trick.css ├── images │ └── ico-delete.png ├── includes │ ├── class-options-framework-admin.php │ ├── class-options-framework.php │ ├── class-options-interface.php │ ├── class-options-media-uploader.php │ └── class-options-sanitization.php ├── js │ ├── media-uploader.js │ ├── options-custom.js │ ├── rebirth.js │ └── trick.js ├── options-framework.php └── trick.php ├── index.php ├── options.php ├── page.php ├── page ├── page-about.php ├── page-archive.php └── page-links.php ├── screenshot.png ├── sidebar.php ├── single.php ├── style.css └── tpl ├── footer ├── footer-info.php └── footer-wave.php ├── home ├── home-hero.php ├── home-pagination.php ├── home-search.php ├── home-thumb.php ├── home-toast.php └── home-totop.php ├── single ├── single-content.php └── single-header.php └── site └── site-wave.php /.gitignore: -------------------------------------------------------------------------------- 1 | # img 2 | *.svg 3 | !jetbrains.svg 4 | 5 | # jetbrains 6 | .idea* -------------------------------------------------------------------------------- /404.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 |
14 |
15 |
16 |
17 |

Error 404

18 |

Page not found

19 | 返回首页 20 |
21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### Version 1.0.5 2 | 3 | 发布日期:2020.04.16 4 | - 📌 修复友链丢失图片和链接bug 08/09 5 | - 🎁 添加文章归档页,优化功能 6 | - ❤ 修复了当菜单没有设置时的错误 7 | - ❤ 修复了默认没有设置分类图片导致的底部出现错误代码 8 | - ✔ 升级Valine 9 | - ✔ 优化底部信息的为空展示 10 | - 🎁 新增后台设置gravatar头像源,默认为极客族,感谢[@MuenYu](https://github.com/MuenYu) 11 | - 🎁 新增面包屑导航 12 | - ❤ 文章页样式微调 13 | - 📌 修复移动端表格错位问题 14 | - ❤ 修复在特定环境下文章表格出现奇怪的问题 15 | - ❤ 修复黑暗模式评论出现奇怪的样式问题 16 | - ❤ 更新Valine为1.4.14,具体配置文件在inc/js/trick.js 17 | 18 | ### Version 1.0.4 19 | 20 | 发布日期:2020.04.07 21 | 22 | - ✔ 修复文章内容添加锚节点不能稳定跳转 23 | - 🎁 新增后台支持弹窗内容和时间 24 | - ❤ 优化博客关键词和文章描述,更利用SEO 25 | 26 | ### Version 1.0.3 27 | 28 | 发布日期:2020.03.17 29 | 30 | - ✔ 修复两个函数判断非数组 31 | - 🎁 新增页脚展示功能 32 | - 🎁 新增友链分类 33 | - ❤ 优化首页文章布局 34 | - ❤ 优化底部信息布局 35 | 36 | ### Version 1.0.2 37 | 38 | 发布日期:2020.03.02 39 | 40 | - ✔ 修复移动端菜单bug 41 | - ❤ 优化 `文章代码` 样式 42 | - ❤ 优化文章外链新标签打开 43 | - ❤ 优化函数,减少动态请求 44 | - ❤ 修改gravatar头像源 45 | - 🎁 新增文章事项清单可视化 46 | - 🎁 后台增加设置图床预加载 47 | - 🎁 增加Logo使用说明 48 | - 🎁 新增404页面 49 | 50 | ### Version 1.0.1 51 | 52 | 发布日期:2020.02.27 53 | 54 | - 粗糙的第一个版本 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 yqchilde 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress Theme - Rebirth 2 | 3 | ![](https://img.shields.io/github/v/release/yqchilde/rebirth.svg?style=flat-square) ![](https://img.shields.io/github/commits-since/yqchilde/rebirth/1.0.5?logo=dev&style=flat-square) 4 | ### 声明 5 | 6 | Rebirth主题的WordPress版本是完全移植过来的,原主题为`JaxsonWang(淮城一只猫)制作`,且是ghost博客主题,详情请看 [点击查看](https://github.com/JaxsonWang/Rebirth) 7 | 8 | ### 特色 9 | 10 | - 大气、简约、优雅以及强大的响应式布局 11 | - 原生黑暗模式,支持 macOS 和 window10 黑暗模式 12 | - 友情链接和关于独立页独特模板,更好展示自己站点 13 | - 恰到好处的个人社交信息 14 | - 适合于中文字体阅读个人文章页面,优化到每一个元素 15 | - [Valine 评论系统](https://valine.js.org/)的支持 16 | - 强大的社交分享文章功能 17 | - 增强模板 SEO 优化 18 | - 更多功能等你来体验 19 | 20 | ### 更新日志 21 | 22 | [更新日志](https://github.com/yqchilde/rebirth/blob/master/CHANGELOG.md) 23 | 24 | ## 使用指南 25 | 26 | ### 下载安装 27 | 28 | - 建议使用 `git clone` 下载 29 | 30 | - 如果直接下载压缩包记载将文件夹名字改回rebirth,即保证主题目录为 `wp-content/themes/rebirth` 31 | 32 | - 请把主题文件包解压去掉master改为rebirth 33 | 34 | - 关于设置主题方面,在wordpress后台里`外观->Rebirth主题设置`里面操作(都有功能描述) 35 | 36 | - 如果发现bug,请及时给我一个issue 37 | 38 | ![](https://pic.yqqy.top/blog/20200227161811.png?imageslim) 39 | 40 | ### 使用前提示 41 | 42 | 1. 主题没有用wordpress默认评论系统,所以没有写默认评论样式。主题用的是 **[Valine.js](https://valine.js.org)** 三方评论系统,是基于`Leancloud`的,申请个人免费开发板足够使用,申请之后的**appId**,**appKey**,**serverUrls** 填入主题设置里面即可享受。 43 | 2. 主题支持**Markdown**文章,这意味着目前不能使用wordpress自带的默认的古腾堡编辑器,这里我推荐大家使用[WP Githuber MD](https://github.com/terrylinooo/githuber-md),这款插件,避免页面某些错位。 44 | 45 | ### 关于页面 46 | 47 | 是基于wordpress编写的独立页面模板,文件在`/page/page-about.php`,如果需要更改,请更改这个源代码 48 | 49 | ### 友链页面 50 | 51 | 是基于wordpress编写的独立页面模板,文件在`/page/page-links.php`,如果需要更改,请更改这个源代码 52 | 53 | 友链分类如果设置了链接分类那么就会显示分类,如果没有设置链接分类那么就不会显示分类 54 | 55 | 友链分类顺序、链接分类顺序,全部是按照`link_id`排序的,也就是说创建顺序,所以请灵活调整 56 | 57 | **添加友链** 58 | 59 | 后台->链接->添加->名称、Web地址、图像描述、图像地址 60 | 61 | ### 新建页面 62 | 63 | 如果需要新建页面,请在`page/`目录下创建`page-xxx.php`文件,`xxx`就是你在页面的链接后缀,模板编写方法可以百度也可以参考友链或者关于页面,然后在wordpress后台->页面->新建页面->页面属性->模板->`自己创建的模板名字)` 64 | 65 | ### tag_ID获取方法 66 | 67 | 关于主题设置分类页面的封面设置里面提到的tag_ID获取方法,详情请看图片 68 | 69 | ![image.png](https://i.loli.net/2020/03/28/83hXRbALpPJoE9Z.png) 70 | ![image.png](https://i.loli.net/2020/03/28/kR6srxdUPtwXqCS.png) 71 | 72 | ### 主题设置 73 | 请在后台->外观->Rebirth主题设置里面填写相关信息,每处都写了解释,如果不懂,请直接给我一个issue。 74 | 75 | ## 插件推荐 76 | 77 | 这里列出我正在用的插件,也代表主题兼容性 78 | 79 | - `External Media without Import` 让你的媒体库插入外链,这意味着每篇文章的特色图片你可以用图床的外链,不用每次上传图片,导致内存大量增加 80 | - `Google XML Sitemaps` 生成sitemap.xml 81 | - `WP Githuber MD` markdown编辑器 82 | - `WP Rocket` 让你的wordpress变得更快(缓存插件) 83 | - `百度搜索推送管理` 自动提交链接给百度站长平台 84 | 85 | ## Support 86 | 87 | >jetbrains 88 | 89 | 90 | 91 | 92 | 93 | ``` 94 | jetbrains有一项开源赞助计划,可以通过开源项目免费申请jetbrains全家桶license 95 | jetbranins官方在赠送license的时候会请求提议加入他们的品牌logo推广放入到仓库中, 96 | 不过这一切都是用户自愿的原则 97 | ``` 98 | 99 | ## License 100 | 101 | WordPress Theme Rebirth is open source and released under the MIT License. -------------------------------------------------------------------------------- /author.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /footer.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
56 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | get( 'Version' ) ); 18 | 19 | if ( ! function_exists( 'rebirth_setup' ) ): 20 | 21 | function rebirth_setup() { 22 | // 开启后台文章特色图 23 | add_theme_support( 'post-thumbnails' ); 24 | set_post_thumbnail_size( 150, 150, true ); 25 | 26 | // 该主题在一个位置使用wp_nav_menu() 27 | register_nav_menus( array( 28 | 'primary' => __( 'Nav Menus', 'rebirth' ), //导航菜单 29 | ) ); 30 | 31 | // 给nav_menu的li添加class 32 | function rebirth_menu_classes( $classes, $item, $args ) { 33 | if ( $args->theme_location == 'primary' ) { 34 | $classes[] = 'nav-item'; 35 | } 36 | 37 | return $classes; 38 | } 39 | 40 | add_filter( 'nav_menu_css_class', 'rebirth_menu_classes', 1, 3 ); 41 | 42 | // 后台添加链接功能 43 | add_filter( 'pre_option_link_manager_enabled', '__return_true' ); 44 | 45 | // 移除wp-block-library-css 46 | add_action( 'wp_enqueue_scripts', 'remove_block_library_css', 100 ); 47 | function remove_block_library_css() { 48 | wp_dequeue_style( 'wp-block-library' ); 49 | } 50 | 51 | // 移除feed 52 | remove_action( 'wp_head', 'feed_links', 2 ); 53 | remove_action( 'wp_head', 'feed_links_extra', 3 ); 54 | // 移除离线编辑器开放接口 55 | remove_action( 'wp_head', 'rsd_link' ); 56 | remove_action( 'wp_head', 'wlwmanifest_link' ); 57 | // 去除本页唯一链接信息 58 | remove_action( 'wp_head', 'index_rel_link' ); 59 | // 清除前后文信息 60 | remove_action( 'wp_head', 'parent_post_rel_link' ); 61 | remove_action( 'wp_head', 'start_post_rel_link' ); 62 | remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); 63 | // 去除版本信息 64 | remove_action( 'wp_head', 'wp_generator' ); 65 | // 移除wp-json链 66 | remove_action( 'wp_head', 'rest_output_link_wp_head' ); 67 | remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 68 | remove_action( 'template_redirect', 'rest_output_link_header', 11 ); 69 | // emoji载入css 70 | remove_action( 'wp_head', 'wp_print_styles', 8 ); 71 | // rel=canonical 72 | remove_action( 'wp_head', 'rel_canonical' ); 73 | // rel=shortlink 74 | remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); 75 | remove_action( 'template_redirect', 'wp_shortlink_header', 11 ); 76 | // 检查并发布将来的帖子 77 | remove_action( 'publish_future_post', 'check_and_publish_future_post', 10 ); 78 | remove_action( 'wp_footer', 'wp_print_footer_scripts' ); 79 | 80 | function my_function_admin_bar() { 81 | return false; 82 | } 83 | 84 | add_filter( 'show_admin_bar', 'my_function_admin_bar' ); 85 | 86 | add_action( 'widgets_init', 'my_remove_recent_comments_style' ); 87 | function my_remove_recent_comments_style() { 88 | global $wp_widget_factory; 89 | remove_action( 'wp_head', array( 90 | $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 91 | 'recent_comments_style' 92 | ) ); 93 | } 94 | 95 | // 禁用表情符号 96 | function disable_emojis() { 97 | remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 98 | remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 99 | remove_action( 'wp_print_styles', 'print_emoji_styles' ); 100 | remove_action( 'admin_print_styles', 'print_emoji_styles' ); 101 | remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 102 | remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 103 | remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 104 | add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); 105 | } 106 | 107 | add_action( 'init', 'disable_emojis' ); 108 | 109 | // 用于删除tinymce表情符号插件的过滤器功能 110 | function disable_emojis_tinymce( $plugins ) { 111 | if ( is_array( $plugins ) ) { 112 | return array_diff( $plugins, array( 'wpemoji' ) ); 113 | } else { 114 | return array(); 115 | } 116 | } 117 | 118 | // 移除菜单冗余代码 119 | add_filter( 'nav_menu_css_class', 'my_css_attributes_filter', 100, 1 ); //删除Class选择器 120 | add_filter( 'nav_menu_item_id', 'my_css_attributes_filter', 100, 1 ); //删除Id选择器 121 | add_filter( 'page_css_class', 'my_css_attributes_filter', 100, 1 ); 122 | function my_css_attributes_filter( $var ) { 123 | return is_array( $var ) ? array_intersect( $var, array( 124 | 'nav-item', 125 | 'current-post-ancestor', 126 | 'current-menu-ancestor', 127 | 'current-menu-parent' 128 | ) ) : ''; 129 | } 130 | 131 | } 132 | 133 | endif; 134 | 135 | add_action( 'after_setup_theme', 'rebirth_setup' ); 136 | 137 | // 引入脚本和样式 138 | function rebirth_scripts() { 139 | 140 | wp_deregister_script( 'jquery' ); 141 | wp_register_script( 'jquery', 'https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js', array(), null, true ); 142 | wp_register_script( 'bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.bundle.min.js', array( 'jquery' ), null, true ); 143 | wp_register_script( 'valine', 'https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js', array(), null, true ); 144 | wp_register_script( 'trick', get_template_directory_uri() . '/inc/js/trick.js', array(), Rebirth_Version, true ); 145 | wp_register_script( 'rebirth', get_template_directory_uri() . '/inc/js/rebirth.js', array(), Rebirth_Version, true ); 146 | 147 | wp_enqueue_script( 'jquery' ); 148 | wp_enqueue_script( 'bootstrap' ); 149 | wp_enqueue_script( 'valine' ); 150 | wp_enqueue_script( 'trick' ); 151 | wp_enqueue_script( 'rebirth' ); 152 | 153 | } 154 | 155 | add_action( 'wp_enqueue_scripts', 'rebirth_scripts' ); 156 | 157 | // 删除自带小工具 158 | function unregister_default_widgets() { 159 | unregister_widget( "WP_Widget_Pages" ); 160 | unregister_widget( "WP_Widget_Calendar" ); 161 | unregister_widget( "WP_Widget_Archives" ); 162 | unregister_widget( "WP_Widget_Links" ); 163 | unregister_widget( "WP_Widget_Meta" ); 164 | unregister_widget( "WP_Widget_Search" ); 165 | unregister_widget( "WP_Widget_Categories" ); 166 | unregister_widget( "WP_Widget_Recent_Posts" ); 167 | unregister_widget( "WP_Nav_Menu_Widget" ); 168 | } 169 | 170 | add_action( "widgets_init", "unregister_default_widgets", 11 ); 171 | 172 | // 分类页面全部添加斜杠,利于SEO 173 | function siren_nice_trailingslashit( $string, $type_of_url ) { 174 | if ( $type_of_url != 'single' ) { 175 | $string = trailingslashit( $string ); 176 | } 177 | 178 | return $string; 179 | } 180 | 181 | add_filter( 'user_trailingslashit', 'siren_nice_trailingslashit', 10, 2 ); 182 | 183 | // 去除链接显示categroy 184 | add_action( 'load-themes.php', 'no_category_base_refresh_rules' ); 185 | add_action( 'created_category', 'no_category_base_refresh_rules' ); 186 | add_action( 'edited_category', 'no_category_base_refresh_rules' ); 187 | add_action( 'delete_category', 'no_category_base_refresh_rules' ); 188 | function no_category_base_refresh_rules() { 189 | global $wp_rewrite; 190 | $wp_rewrite->flush_rules(); 191 | } 192 | 193 | // Remove category base 194 | add_action( 'init', 'no_category_base_permastruct' ); 195 | function no_category_base_permastruct() { 196 | global $wp_rewrite, $wp_version; 197 | if ( version_compare( $wp_version, '3.4', '<' ) ) { 198 | 199 | } else { 200 | $wp_rewrite->extra_permastructs['category']['struct'] = '%category%'; 201 | } 202 | } 203 | 204 | // Add our custom category rewrite rules 205 | add_filter( 'category_rewrite_rules', 'no_category_base_rewrite_rules' ); 206 | function no_category_base_rewrite_rules( $category_rewrite ) { 207 | //var_dump($category_rewrite); // For Debugging 208 | $category_rewrite = array(); 209 | $categories = get_categories( array( 'hide_empty' => false ) ); 210 | foreach ( $categories as $category ) { 211 | $category_nicename = $category->slug; 212 | if ( $category->parent == $category->cat_ID )// recursive recursion 213 | { 214 | $category->parent = 0; 215 | } elseif ( $category->parent != 0 ) { 216 | $category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename; 217 | } 218 | $category_rewrite[ '(' . $category_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$' ] = 'index.php?category_name=$matches[1]&feed=$matches[2]'; 219 | $category_rewrite[ '(' . $category_nicename . ')/page/?([0-9]{1,})/?$' ] = 'index.php?category_name=$matches[1]&paged=$matches[2]'; 220 | $category_rewrite[ '(' . $category_nicename . ')/?$' ] = 'index.php?category_name=$matches[1]'; 221 | } 222 | // Redirect support from Old Category Base 223 | global $wp_rewrite; 224 | $old_category_base = get_option( 'category_base' ) ? get_option( 'category_base' ) : 'category'; 225 | $old_category_base = trim( $old_category_base, '/' ); 226 | $category_rewrite[ $old_category_base . '/(.*)$' ] = 'index.php?category_redirect=$matches[1]'; 227 | 228 | //var_dump($category_rewrite); // For Debugging 229 | return $category_rewrite; 230 | } 231 | 232 | // Add 'category_redirect' query variable 233 | add_filter( 'query_vars', 'no_category_base_query_vars' ); 234 | function no_category_base_query_vars( $public_query_vars ) { 235 | $public_query_vars[] = 'category_redirect'; 236 | 237 | return $public_query_vars; 238 | } 239 | 240 | // Redirect if 'category_redirect' is set 241 | add_filter( 'request', 'no_category_base_request' ); 242 | function no_category_base_request( $query_vars ) { 243 | //print_r($query_vars); // For Debugging 244 | if ( isset( $query_vars['category_redirect'] ) ) { 245 | $catlink = trailingslashit( get_option( 'home' ) ) . user_trailingslashit( $query_vars['category_redirect'], 'category' ); 246 | status_header( 301 ); 247 | header( "Location: $catlink" ); 248 | exit(); 249 | } 250 | 251 | return $query_vars; 252 | } 253 | 254 | // 去掉Wordpress挂件 255 | function disable_dashboard_widgets() { 256 | remove_meta_box( 'dashboard_primary', 'dashboard', 'core' );//wordpress博客 257 | remove_meta_box( 'dashboard_secondary', 'dashboard', 'core' );//wordpress其它新闻 258 | remove_meta_box( 'dashboard_right_now', 'dashboard', 'core' );//wordpress概况 259 | } 260 | 261 | add_action( 'admin_menu', 'disable_dashboard_widgets' ); 262 | 263 | // 去除后台显示底部文字 264 | function my_admin_footer_text() { 265 | return ''; 266 | } 267 | 268 | // 去除后台显示版本信息 269 | function my_update_footer() { 270 | return ''; 271 | } 272 | 273 | add_filter( 'admin_footer_text', 'my_admin_footer_text', 10 ); 274 | add_filter( 'update_footer', 'my_update_footer', 50 ); 275 | 276 | // 调用Utils库做一些自定义的活 277 | require get_template_directory() . '/inc/Utils.php'; 278 | -------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | > 13 | 14 | 15 | 16 | 18 | <?php if ( is_home() ) { 19 | bloginfo( 'name' ); 20 | echo " - "; 21 | bloginfo( 'description' ); 22 | } elseif ( is_category() ) { 23 | single_cat_title(); 24 | echo " - "; 25 | bloginfo( 'name' ); 26 | } elseif ( is_single() || is_page() ) { 27 | single_post_title(); 28 | echo " - "; 29 | bloginfo( 'description' ); 30 | } elseif ( is_404() ) { 31 | echo '页面未找到!'; 32 | echo " - "; 33 | bloginfo( 'description' ); 34 | } else { 35 | wp_title( '', true ); 36 | echo " - "; 37 | bloginfo( 'description' ); 38 | } ?> 39 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | 74 |
75 | 76 | 77 |
78 | 118 |
119 | -------------------------------------------------------------------------------- /images/jetbrains.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 39 | 40 | 41 | 42 | 43 | 45 | 47 | 48 | 51 | 54 | 56 | 57 | 59 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /images/post.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqchilde/rebirth/ff5e3e06019d041fa59e8a633c178953f7a5f701/images/post.jpg -------------------------------------------------------------------------------- /inc/Utils.php: -------------------------------------------------------------------------------- 1 | 400 ) { 65 | return mb_strcut( $post_excerpt, 0, 400, 'utf-8' ) . '...'; 66 | } else { 67 | return mb_strcut( $post_excerpt, 0, 400, 'utf-8' ); 68 | } 69 | } elseif ( $type == 'single' ) { 70 | if ( strlen( $post_excerpt ) == 0 ) { 71 | return ''; 72 | } else if ( strlen( $post_excerpt ) > 280 ) { 73 | return mb_strcut( $post_excerpt, 0, 280, 'utf-8' ) . '...'; 74 | } else { 75 | return mb_strcut( $post_excerpt, 0, 280, 'utf-8' ); 76 | } 77 | } else { 78 | return null; 79 | } 80 | } 81 | 82 | // 设置nav的a标签中的class和data-link-alt属性 83 | function rebirth_menu_link_attr( $attr, $item ) { 84 | $attr['class'] = 'nav-link'; 85 | $attr['data-link-alt'] = $item->title; 86 | 87 | return $attr; 88 | } 89 | 90 | add_filter( 'nav_menu_link_attributes', 'rebirth_menu_link_attr', 10, 3 ); 91 | 92 | // 给分页导航 next_posts_link api 添加属性 93 | function rebirth_next_posts_link_attributes() { 94 | return 'class="page-link"' . 'aria-label="下一页"'; 95 | } 96 | 97 | add_filter( 'next_posts_link_attributes', 'rebirth_next_posts_link_attributes' ); 98 | 99 | // 给分页导航 previous_posts_link api 添加属性 100 | function rebirth_prev_posts_link_attributes() { 101 | return 'class="page-link"' . 'aria-label="上一页"'; 102 | } 103 | 104 | add_filter( 'previous_posts_link_attributes', 'rebirth_prev_posts_link_attributes' ); 105 | 106 | // 获取阅读数量 107 | function getPostViews( $postID ) { 108 | $count_key = 'post_views_count'; 109 | $count = get_post_meta( $postID, $count_key, true ); 110 | if ( $count == '' ) { 111 | delete_post_meta( $postID, $count_key ); 112 | add_post_meta( $postID, $count_key, '0' ); 113 | 114 | return "0"; 115 | } 116 | 117 | return $count; 118 | } 119 | 120 | // 设置或更新阅读数量 121 | function setPostViews( $postID ) { 122 | $count_key = 'post_views_count'; 123 | $count = get_post_meta( $postID, $count_key, true ); 124 | if ( $count == '' ) { 125 | delete_post_meta( $postID, $count_key ); 126 | add_post_meta( $postID, $count_key, '0' ); 127 | } else { 128 | $count ++; 129 | update_post_meta( $postID, $count_key, $count ); 130 | } 131 | } 132 | 133 | // Gravatar头像使用中国服务器 134 | function gravatar_cn( $url ) { 135 | $gravatar_url = array( '0.gravatar.com', '1.gravatar.com', '2.gravatar.com', 'secure.gravatar.com' ); 136 | 137 | if ( rebirth_option( 'gravatar_source' ) ) { 138 | return str_replace( $gravatar_url, rebirth_option( 'gravatar_source' ), $url ); 139 | } 140 | 141 | return str_replace( $gravatar_url, 'sdn.geekzu.org', $url ); 142 | } 143 | 144 | add_filter( 'get_avatar_url', 'gravatar_cn', 4 ); 145 | 146 | // 获取相邻文章缩略图 上一篇 147 | function getPrevThumbnailUrl() { 148 | $prev_post = get_previous_post(); 149 | if ( ! $prev_post ) { 150 | return getThumbnail(); // 首页图 151 | } else { 152 | return isHaveThumbnailInArticle( $prev_post ); 153 | } 154 | } 155 | 156 | // 下一篇 157 | function getNextThumbnailUrl() { 158 | return isHaveThumbnailInArticle( get_next_post() ); 159 | } 160 | 161 | // 判断文章中是否有缩略图 162 | function isHaveThumbnailInArticle( $obj ) { 163 | if ( has_post_thumbnail( $obj->ID ) ) { 164 | $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $obj->ID ), 'large' ); 165 | 166 | return $img_src[0]; 167 | } else { 168 | $content = $obj->post_content; 169 | preg_match_all( '//sim', $content, $strResult, PREG_PATTERN_ORDER ); 170 | $n = count( $strResult[1] ); 171 | if ( $n > 0 ) { 172 | return $strResult[1][0]; 173 | } else { 174 | return getThumbnail(); 175 | } 176 | } 177 | } 178 | 179 | // 获取当前分类文章总数 180 | function getCurrentCategoryCount() { 181 | $cat_ID = get_query_var( 'cat' ); 182 | 183 | return get_category( $cat_ID )->count; 184 | } 185 | 186 | // 友情链接 187 | function getTheLinkItems( $id = null ) { 188 | $bookmarks = get_bookmarks( 'orderby=link_id&category=' . $id ); 189 | $linksInfo = []; 190 | if ( ! empty( $bookmarks ) ) { 191 | foreach ( $bookmarks as $k => $bookmark ) { 192 | if ( empty( $bookmark->link_description ) ) { 193 | $bookmark->link_description = 'This guy is so lazy ╮(╯▽╰)╭'; 194 | } 195 | if ( empty( $bookmark->link_image ) ) { 196 | $bookmark->link_image = 'https://pic.yqqy.top/blog/20200223184800.png?imageslim'; 197 | } 198 | $linksInfo[ $k ]["link_url"] = $bookmark->link_url; 199 | $linksInfo[ $k ]["link_name"] = $bookmark->link_name; 200 | $linksInfo[ $k ]["link_image"] = $bookmark->link_image; 201 | $linksInfo[ $k ]["link_description"] = $bookmark->link_description; 202 | } 203 | } 204 | 205 | return $linksInfo; 206 | } 207 | 208 | // 获取分类页面描述 209 | function getCategoryDescription( $info ) { 210 | if ( $info == "name" ) { 211 | return get_category( get_query_var( 'cat' ) )->name; 212 | } else if ( $info == "description" ) { 213 | return get_category( get_query_var( 'cat' ) )->description; 214 | } else { 215 | return null; 216 | } 217 | 218 | return null; 219 | } 220 | 221 | // 实时搜索路由 222 | add_action( 'rest_api_init', function () { 223 | 224 | register_rest_route( 'rebirth/v1', '/cache_search/json', array( 225 | 'methods' => 'GET', 226 | 'callback' => 'cacheSearchJson', 227 | ) ); 228 | 229 | } ); 230 | 231 | // 实时搜索rest api 232 | function cacheSearchJson() { 233 | $vowels = array( 234 | "[", 235 | "{", 236 | "]", 237 | "}", 238 | "<", 239 | ">", 240 | "\r\n", 241 | "\r", 242 | "\n", 243 | "-", 244 | "'", 245 | '"', 246 | '`', 247 | " ", 248 | ":", 249 | ";", 250 | '\\', 251 | " ", 252 | "toc" 253 | ); 254 | $regex = <<])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m 256 | EOS; 257 | 258 | $output = ''; 259 | $posts = new WP_Query( 'posts_per_page=-1&post_status=publish&post_type=post' ); 260 | while ( $posts->have_posts() ): $posts->the_post(); 261 | $output .= '{"type":"post","link":"' . get_permalink() . '","title":' . json_encode( get_the_title() ) . ',"time":"' . get_the_time( 'Y-m-d', $posts->ID ) . '","text":' . json_encode( str_replace( $vowels, " ", preg_replace( $regex, ' ', get_the_content() ) ) ) . '},'; 262 | endwhile; 263 | wp_reset_postdata(); 264 | 265 | $pages = get_pages(); 266 | foreach ( $pages as $page ) { 267 | $output .= '{"type":"page","link":"' . get_page_link( $page ) . '","title":' . json_encode( $page->post_title ) . ',"time":"' . get_the_time( 'Y-m-d', $posts->ID ) . '","text":' . json_encode( str_replace( $vowels, " ", preg_replace( $regex, ' ', $page->post_content ) ) ) . '},'; 268 | } 269 | 270 | $output = substr( $output, 0, strlen( $output ) - 1 ); 271 | 272 | $data = '[' . $output . ']'; 273 | $result = new WP_REST_Response( json_decode( $data ), 200 ); 274 | $result->set_headers( 275 | array( 276 | 'Content-Type' => 'application/json', 277 | 'Cache-Control' => 'max-age=3600', 278 | ) 279 | ); 280 | 281 | return $result; 282 | } 283 | 284 | // 获取后台设置的分类封面图 285 | function getCategoryBgImg() { 286 | return json_decode( rebirth_option( 'site_category_img' ) ); 287 | } 288 | 289 | // seo优化(文章内容新窗口打开+nofollow) 290 | function autoLinkNoFollow( $content ) { 291 | $regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>"; 292 | if ( preg_match_all( "/$regexp/siU", $content, $matches, PREG_SET_ORDER ) ) { 293 | if ( ! empty( $matches ) ) { 294 | $srcUrl = get_option( 'siteurl' ); 295 | for ( $i = 0; $i < count( $matches ); $i ++ ) { 296 | $tag = $matches[ $i ][0]; 297 | $tag2 = $matches[ $i ][0]; 298 | $url = $matches[ $i ][0]; 299 | $noFollow = ''; 300 | $pattern = ''; 301 | preg_match( $pattern, $tag2, $match, PREG_OFFSET_CAPTURE ); 302 | if ( $match[1][0][0] != "#" ) { 303 | $pattern = '/target\s*=\s*"\s*_blank\s*"/'; 304 | preg_match( $pattern, $tag2, $match, PREG_OFFSET_CAPTURE ); 305 | if ( count( $match ) < 1 ) { 306 | $noFollow .= ' target="_blank" '; 307 | } 308 | $pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/'; 309 | preg_match( $pattern, $tag2, $match, PREG_OFFSET_CAPTURE ); 310 | if ( count( $match ) < 1 ) { 311 | $noFollow .= ' rel="nofollow" '; 312 | } 313 | } 314 | $pos = strpos( $url, $srcUrl ); 315 | if ( $pos === false ) { 316 | $tag = rtrim( $tag, '>' ); 317 | $tag .= $noFollow . '>'; 318 | $content = str_replace( $tag2, $tag, $content ); 319 | } 320 | } 321 | } 322 | } 323 | 324 | $content = str_replace( ']]>', ']]>', $content ); 325 | 326 | return $content; 327 | } 328 | 329 | // 获取网站底部导航信息 330 | function getSiteNavInfo() { 331 | return json_decode( rebirth_option( 'site_bottom_nav_info' ) ); 332 | } 333 | 334 | // 提取默认avatar的src 335 | function getAvatarUrl( $avatarLink ) { 336 | preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatarLink, $matches ); 337 | 338 | if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) { 339 | return esc_url_raw( $matches[1] ); 340 | } 341 | 342 | return ''; 343 | } 344 | 345 | // 文章关键词seo description优化 346 | function wp_description() { 347 | global $s, $post; 348 | $description = ''; 349 | $blog_name = get_bloginfo( 'name' ); 350 | if ( is_singular() ) { //文章页如果存在描述字段,则显示描述,否则截取文章内容 351 | if ( ! empty ( $post->post_excerpt ) ) { 352 | $text = $post->post_excerpt; 353 | } else { 354 | $text = $post->post_content; 355 | } 356 | $description = trim( str_replace( array( 357 | "\r\n", 358 | "\r", 359 | "\n", 360 | " ", 361 | " " 362 | ), " ", str_replace( "\"", "'", strip_tags( $text ) ) ) ); 363 | if ( ! ( $description ) ) { 364 | $description = $blog_name . "-" . trim( wp_title( '', false ) ); 365 | } 366 | } elseif ( is_home() ) {//首页显示描述设置 367 | $description = rebirth_option( 'site_meta_description' ); // 首頁要自己加 368 | } elseif ( is_tag() ) {//标签页显示描述设置 369 | $description = $blog_name . "有关 '" . single_tag_title( '', false ) . "' 的文章"; 370 | } elseif ( is_category() ) {//分类页显示描述设置 371 | $description = $blog_name . "有关 '" . single_cat_title( '', false ) . "' 的文章"; 372 | } elseif ( is_archive() ) {//文档页显示描述设置 373 | $description = $blog_name . "在: '" . trim( wp_title( '', false ) ) . "' 的文章"; 374 | } elseif ( is_search() ) {//搜索页显示描述设置 375 | $description = $blog_name . ": '" . esc_html( $s, 1 ) . "' 的搜索結果"; 376 | } else {//默认其他页显示描述设置 377 | $description = $blog_name . "有关 '" . trim( wp_title( '', false ) ) . "' 的文章"; 378 | } 379 | 380 | //输出描述 381 | return $description = mb_substr( $description, 0, 220, 'utf-8' ) . '..'; 382 | } 383 | 384 | // 文章关键词seo keywords优化 385 | function wp_keywords() { 386 | global $s, $post; 387 | $keywords = ''; 388 | if ( is_single() ) { //如果是文章页,关键词则是:标签+分类ID 389 | if ( get_the_tags( $post->ID ) ) { 390 | foreach ( get_the_tags( $post->ID ) as $tag ) { 391 | $keywords .= $tag->name . ', '; 392 | } 393 | } 394 | foreach ( get_the_category( $post->ID ) as $category ) { 395 | $keywords .= $category->cat_name . ', '; 396 | } 397 | $keywords = substr_replace( $keywords, '', - 2 ); 398 | } elseif ( is_home() ) { 399 | $keywords = rebirth_option( 'site_meta_keywords' ); //主页关键词设置 400 | } elseif ( is_tag() ) { //标签页关键词设置 401 | $keywords = single_tag_title( '', false ); 402 | } elseif ( is_category() ) {//分类页关键词设置 403 | $keywords = single_cat_title( '', false ); 404 | } elseif ( is_search() ) {//搜索页关键词设置 405 | $keywords = esc_html( $s, 1 ); 406 | } else {//默认页关键词设置 407 | $keywords = trim( wp_title( '', false ) ); 408 | } 409 | if ( $keywords ) { //输出关键词 410 | return $keywords; 411 | } 412 | 413 | return ""; 414 | } 415 | 416 | // 默认文章底部图 417 | function getSingleBottomImg() { 418 | return "/wp-content/themes/rebirth" . rebirth_option( 'default_img' ); 419 | } 420 | -------------------------------------------------------------------------------- /inc/css/optionsframework.css: -------------------------------------------------------------------------------- 1 | /* Options Framework Admin Styles */ 2 | 3 | body { 4 | font-family:miranafont,"Hiragino Sans GB",STXihei,"Microsoft YaHei",SimSun,sans-serif; 5 | background:#F5F5F5 ; 6 | height: auto; 7 | } 8 | 9 | .explain { 10 | white-space: pre-line; 11 | } 12 | 13 | .nav-tab-wrapper { 14 | position: relative; 15 | max-width: 860px; 16 | margin: auto !important; 17 | } 18 | 19 | .wrap h2.nav-tab-wrapper { 20 | border-bottom:none 21 | } 22 | 23 | .metabox-holder { 24 | padding-top:0 !important 25 | } 26 | 27 | .nav-tab-active { 28 | border-bottom: none; 29 | background: #fff; 30 | color: #000; 31 | border:none; 32 | font-weight: 300; 33 | font-size: 18px; 34 | color: #4B6894; 35 | } 36 | 37 | .nav-tab-active:hover { 38 | background: #fff; 39 | } 40 | 41 | .nav-tab { 42 | background: none; 43 | border:none; 44 | padding: 10px 20px; 45 | font-weight: 300; 46 | font-size: 15px; 47 | color: darkgoldenrod; 48 | border-radius: 3px 3px 0 0; 49 | } 50 | 51 | .nav-tab-active { 52 | background:#fff 53 | } 54 | 55 | a#options-group-1-tab:before { 56 | font-family: "dashicons"; 57 | content: "\f111"; 58 | float: left; 59 | } 60 | 61 | a#options-group-2-tab:before { 62 | font-family: "dashicons"; 63 | content: "\f110"; 64 | float: left; 65 | } 66 | 67 | a#options-group-3-tab:before { 68 | font-family: "dashicons"; 69 | content: "\f237"; 70 | float: left; 71 | } 72 | 73 | a#options-group-4-tab:before { 74 | font-family: "dashicons"; 75 | content: "\f537"; 76 | float: left; 77 | } 78 | 79 | input[type=checkbox], input[type=radio] { 80 | border: 1px solid #b4b9be; 81 | background: #fff; 82 | color: #555; 83 | clear: none; 84 | cursor: pointer; 85 | display: inline-block; 86 | line-height: 0; 87 | height: 16px; 88 | margin: -4px 4px 0 0; 89 | outline: none; 90 | padding: 0!important; 91 | text-align: center; 92 | vertical-align: middle; 93 | width: 16px; 94 | min-width: 16px; 95 | box-shadow: none 96 | } 97 | 98 | input[type="button"]{ 99 | box-shadow: none !important; 100 | border: none !important; 101 | background:#FF5858 !important; 102 | color:#fff !important 103 | } 104 | 105 | input[type=text], 106 | input[type=password], 107 | input[type=checkbox], 108 | input[type=color], 109 | input[type=date], 110 | input[type=datetime], 111 | input[type=datetime-local], 112 | input[type=email], 113 | input[type=month], 114 | input[type=number], 115 | input[type=radio], 116 | input[type=tel], 117 | input[type=time], 118 | input[type=url], 119 | input[type=week], 120 | input[type=search], 121 | select, textarea{ 122 | box-shadow:none 123 | } 124 | input[type="submit" i], input[type="reset" i]{ 125 | 126 | } 127 | 128 | #optionsframework h4 { 129 | font-weight:300; 130 | font-size: 15px 131 | } 132 | #optionsframework { 133 | position:relative; 134 | z-index: 0; 135 | max-width:860px; 136 | background:#FBFBFB; 137 | padding: 30px; 138 | margin: auto; 139 | box-shadow: none; 140 | border: none; 141 | border: 1px solid #fff; 142 | border-radius: 3px; 143 | } 144 | #optionsframework h3 { 145 | cursor: default; 146 | cursor: default; 147 | font-size: 20px; 148 | font-weight: 600; 149 | color: #3F607D; 150 | display: none; 151 | } 152 | #optionsframework p { 153 | margin-bottom:0; 154 | padding-bottom:10px; 155 | line-height: 1.4em; 156 | } 157 | #optionsframework .section { 158 | padding: 10px; 159 | margin-bottom: 20px; 160 | padding-bottom: 30px; 161 | border-bottom: 1px solid #E8E8E8; 162 | } 163 | #optionsframework .group { 164 | padding-bottom:40px; 165 | } 166 | #optionsframework .section .heading { 167 | padding:10px 0px; 168 | margin:0 0 15px; 169 | font-weight: 600; 170 | color: #455E8C; 171 | } 172 | #optionsframework .section .controls { 173 | float: left; 174 | min-width:350px; 175 | width: 54%; 176 | padding-right:2%; 177 | } 178 | #optionsframework .section .explain { 179 | max-width:38%; 180 | float: left; 181 | font-size: 12px; 182 | line-height:20px; 183 | color: #777; 184 | } 185 | #optionsframework .section-checkbox .controls { 186 | width: 98%; 187 | } 188 | #optionsframework .section-checkbox .explain { 189 | max-width:94%; 190 | } 191 | #optionsframework .of-input { 192 | width:100%; 193 | } 194 | #optionsframework .controls select, #optionsframework .controls textarea { 195 | margin-bottom:10px; 196 | width:100%; 197 | } 198 | #optionsframework .section-radio label, #optionsframework .section-multicheck label { 199 | float:left; 200 | max-width:90%; 201 | line-height: 16px; 202 | margin-bottom: 5px; 203 | } 204 | #optionsframework input.checkbox, #optionsframework input.of-radio { 205 | width: 15px; 206 | margin-top:2px; 207 | float:left; 208 | clear:both; 209 | border-radius: 50%; 210 | } 211 | #optionsframework .section-typography .controls { 212 | float:none; 213 | width:auto; 214 | } 215 | #optionsframework .section-typography .explain { 216 | float:none; 217 | width:auto; 218 | } 219 | #optionsframework .controls .of-typography-size { 220 | width:80px; 221 | float:left 222 | } 223 | #optionsframework .controls .of-typography-unit { 224 | width:50px; 225 | margin-left:5px; 226 | float:left 227 | } 228 | #optionsframework .controls .of-typography-face { 229 | width:100px; 230 | margin-left:5px; 231 | float:left 232 | } 233 | #optionsframework .controls .of-typography-style { 234 | width:80px; 235 | margin-left:5px; 236 | margin-right:5px; 237 | float:left 238 | } 239 | #optionsframework .of-background-properties { 240 | clear:both; 241 | margin-top: 18px; 242 | } 243 | #optionsframework .controls .of-background-repeat { 244 | width:125px; 245 | margin-right:5px; 246 | float:left 247 | } 248 | #optionsframework .controls .of-background-position { 249 | width:125px; 250 | margin-right:5px; 251 | float:left 252 | } 253 | #optionsframework .controls .of-background-attachment { 254 | width:125px; 255 | margin-right:5px; 256 | float:left 257 | } 258 | #optionsframework .section-background .wp-picker-container { 259 | margin-bottom:10px; 260 | } 261 | #optionsframework .controls .of-radio-img-img { 262 | border:3px solid #f9f9f9; 263 | margin:0 5px 10px 0; 264 | display:none; 265 | cursor:pointer; 266 | float:left; 267 | } 268 | #optionsframework .controls .of-radio-img-selected { 269 | border:3px solid #ccc 270 | } 271 | #optionsframework .controls .of-radio-img-img:hover { 272 | opacity:.8; 273 | } 274 | #optionsframework .controls .of-border-width { 275 | width:80px; 276 | float:left 277 | } 278 | #optionsframework .controls .of-border-style { 279 | width:120px; 280 | float:left 281 | } 282 | #optionsframework .hide { 283 | display:none; 284 | } 285 | #optionsframework .of-option-image { 286 | max-width:340px; 287 | margin:3px 0 18px 0; 288 | } 289 | #optionsframework .mini .controls select, #optionsframework .section .mini .controls { 290 | width: 140px; 291 | } 292 | #optionsframework .mini .controls input, #optionsframework .mini .controls { 293 | min-width:140px; 294 | width: 140px; 295 | } 296 | #optionsframework .mini .explain { 297 | max-width:74%; 298 | } 299 | 300 | /* Editor */ 301 | 302 | #optionsframework .section-editor .explain { 303 | max-width: 98%; 304 | float:none; 305 | margin-bottom:5px; 306 | } 307 | 308 | /* Image Uploader */ 309 | 310 | #optionsframework .controls input.upload { 311 | width:80%; 312 | box-shadow: none; 313 | } 314 | #optionsframework .controls input.upload_button { 315 | float:right; 316 | border-color:#BBBBBB; 317 | cursor:pointer; 318 | } 319 | #optionsframework .controls input.upload_button:hover { 320 | border-color:#666666; 321 | color:#000; 322 | } 323 | #optionsframework .screenshot { 324 | float:left; 325 | margin-left:1px; 326 | position:relative; 327 | width:150px; 328 | margin-top:20px; 329 | } 330 | #optionsframework .screenshot img { 331 | background:#FAFAFA; 332 | border-color:#ccc #eee #eee #ccc; 333 | border-style:solid; 334 | border-width:1px; 335 | float:left; 336 | max-width:334px; 337 | max-height: 130px; 338 | padding:4px; 339 | margin-bottom:10px; 340 | } 341 | #optionsframework .screenshot .remove-image { 342 | background:url("../images/ico-delete.png") no-repeat; 343 | border:medium none; 344 | bottom:4px; 345 | display:block; 346 | float:left; 347 | height:16px; 348 | padding:0; 349 | position:absolute; 350 | left:-4px; 351 | text-indent:-9999px; 352 | width:16px; 353 | } 354 | #optionsframework .screenshot .no_image .file_link { 355 | margin-left: 20px; 356 | } 357 | #optionsframework .screenshot .no_image .remove-button { 358 | bottom: 0px; 359 | } 360 | #optionsframework .reset-button { 361 | float: left; 362 | box-shadow: none; 363 | border: none; 364 | background: #374D6F; 365 | text-shadow: none; 366 | color:#fff; 367 | height: 40px; 368 | width: 100px; 369 | border-radius: 0px; 370 | cursor:pointer; 371 | } 372 | 373 | /* Bottom Section */ 374 | 375 | #optionsframework-submit { 376 | padding: 7px 10px; 377 | background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC); 378 | } 379 | #optionsframework .button-primary { 380 | float: right; 381 | box-shadow: none; 382 | border: none; 383 | background: #FF6464; 384 | text-shadow: none; 385 | /* padding: 10px; */ 386 | height: 40px; 387 | width: 100px; 388 | border-radius: 0px; 389 | } 390 | #optionsframework .section:after { 391 | content: ""; 392 | display: table; 393 | } 394 | #optionsframework .section:after { 395 | clear: both; 396 | } 397 | 398 | input.of-radio-img-radio{display: none;} 399 | .of-radio-img-label{display: none;} 400 | .of-radio-color{ 401 | display: inline-block;width: 20px;height: 20px;margin: 0 5px 0 0; 402 | } 403 | #optionsframework .controls .of-radio-img-img { 404 | border:3px solid #f9f9f9; 405 | margin:0 5px 10px 0; 406 | /*display:none;*/ 407 | cursor:pointer; 408 | float:left; 409 | } 410 | #optionsframework .controls .of-radio-img-selected { 411 | border:3px solid #ccc 412 | } 413 | #optionsframework .controls .of-radio-img-img:hover { 414 | opacity:.8; 415 | } 416 | #optionsframework .controls .of-border-width { 417 | width:80px; 418 | float:left 419 | } 420 | #optionsframework .controls .of-border-style { 421 | width:120px; 422 | float:left 423 | } 424 | 425 | 426 | #optionsframework .section-color .controls, 427 | #optionsframework .section-colorradio .controls, 428 | #optionsframework .section-radio .controls{float: none;width: 100%;overflow: hidden;margin-bottom: 5px;} 429 | 430 | #optionsframework .section-color .explain, 431 | #optionsframework .section-colorradio .explain, 432 | #optionsframework .section-radio .explain{float: none;width: 100%;} 433 | -------------------------------------------------------------------------------- /inc/css/trick.css: -------------------------------------------------------------------------------- 1 | .search-wrapper{width:422px;max-width:100%}#search-span{font-size:.875rem}/*!*在992 和1199 像素之间的屏幕里,中等屏幕,分辨率低的PC*!*//*!*在768 和991 像素之间的屏幕里,小屏幕,主要是PAD*!*//*!*在480 和767 像素之间的屏幕里,超小屏幕,主要是手机*!*//*!*在小于480 像素的屏幕,微小屏幕,更低分辨率的手机*!*/ -------------------------------------------------------------------------------- /inc/images/ico-delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqchilde/rebirth/ff5e3e06019d041fa59e8a633c178953f7a5f701/inc/images/ico-delete.png -------------------------------------------------------------------------------- /inc/includes/class-options-framework-admin.php: -------------------------------------------------------------------------------- 1 | 5 | * @license GPL-2.0+ 6 | * @link http://wptheming.com 7 | * @copyright 2010-2014 WP Theming 8 | */ 9 | 10 | class Options_Framework_Admin { 11 | 12 | /** 13 | * Page hook for the options screen 14 | * 15 | * @since 1.7.0 16 | * @type string 17 | */ 18 | protected $options_screen = null; 19 | 20 | /** 21 | * Hook in the scripts and styles 22 | * 23 | * @since 1.7.0 24 | */ 25 | public function init() { 26 | 27 | // Gets options to load 28 | $options = & Options_Framework::_optionsframework_options(); 29 | 30 | // Checks if options are available 31 | if ( $options ) { 32 | 33 | // Add the options page and menu item. 34 | add_action( 'admin_menu', array( $this, 'add_custom_options_page' ) ); 35 | 36 | // Add the required scripts and styles 37 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); 38 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); 39 | 40 | // Settings need to be registered after admin_init 41 | add_action( 'admin_init', array( $this, 'settings_init' ) ); 42 | 43 | // Adds options menu to the admin bar 44 | add_action( 'wp_before_admin_bar_render', array( $this, 'optionsframework_admin_bar' ) ); 45 | 46 | } 47 | 48 | } 49 | 50 | /** 51 | * Registers the settings 52 | * 53 | * @since 1.7.0 54 | */ 55 | function settings_init() { 56 | 57 | // Get the option name 58 | $options_framework = new Options_Framework; 59 | $name = $options_framework->get_option_name(); 60 | 61 | // Registers the settings fields and callback 62 | register_setting( 'optionsframework', $name, array ( $this, 'validate_options' ) ); 63 | 64 | // Displays notice after options save 65 | add_action( 'optionsframework_after_validate', array( $this, 'save_options_notice' ) ); 66 | 67 | } 68 | 69 | /* 70 | * Define menu options 71 | * 72 | * Examples usage: 73 | * 74 | * add_filter( 'optionsframework_menu', function( $menu ) { 75 | * $menu['page_title'] = 'The Options'; 76 | * $menu['menu_title'] = 'The Options'; 77 | * return $menu; 78 | * }); 79 | * 80 | * @since 1.7.0 81 | * 82 | */ 83 | static function menu_settings() { 84 | 85 | $menu = array( 86 | 87 | // Modes: submenu, menu 88 | 'mode' => 'submenu', 89 | 90 | // Submenu default settings 91 | 'page_title' => __( '', 'textdomain' ), 92 | 'menu_title' => __( 'Rebirth主题设置', 'textdomain' ), 93 | 'capability' => 'edit_theme_options', 94 | 'menu_slug' => 'options-framework', 95 | 'parent_slug' => 'themes.php', 96 | 97 | // Menu default settings 98 | 'icon_url' => 'dashicons-admin-generic', 99 | 'position' => '61' 100 | 101 | ); 102 | 103 | return apply_filters( 'optionsframework_menu', $menu ); 104 | } 105 | 106 | /** 107 | * Add a subpage called "Theme Options" to the appearance menu. 108 | * 109 | * @since 1.7.0 110 | */ 111 | function add_custom_options_page() { 112 | 113 | $menu = $this->menu_settings(); 114 | 115 | // If you want a top level menu, see this Gist: 116 | // https://gist.github.com/devinsays/884d6abe92857a329d99 117 | 118 | // Code removed because it conflicts with .org theme check. 119 | 120 | $this->options_screen = add_theme_page( 121 | $menu['page_title'], 122 | $menu['menu_title'], 123 | $menu['capability'], 124 | $menu['menu_slug'], 125 | array( $this, 'options_page' ) 126 | ); 127 | 128 | } 129 | 130 | /** 131 | * Loads the required stylesheets 132 | * 133 | * @since 1.7.0 134 | */ 135 | 136 | function enqueue_admin_styles( $hook ) { 137 | 138 | if ( $this->options_screen != $hook ) 139 | return; 140 | 141 | wp_enqueue_style( 'optionsframework', OPTIONS_FRAMEWORK_DIRECTORY . 'css/optionsframework.css', array(), Options_Framework::VERSION ); 142 | wp_enqueue_style( 'wp-color-picker' ); 143 | } 144 | 145 | /** 146 | * Loads the required javascript 147 | * 148 | * @since 1.7.0 149 | */ 150 | function enqueue_admin_scripts( $hook ) { 151 | 152 | if ( $this->options_screen != $hook ) 153 | return; 154 | 155 | // Enqueue custom option panel JS 156 | wp_enqueue_script( 'options-custom', OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ), Options_Framework::VERSION ); 157 | 158 | // Inline scripts from options-interface.php 159 | add_action( 'admin_head', array( $this, 'of_admin_head' ) ); 160 | } 161 | 162 | function of_admin_head() { 163 | // Hook to add custom scripts 164 | do_action( 'optionsframework_custom_scripts' ); 165 | } 166 | 167 | /** 168 | * Builds out the options panel. 169 | * 170 | * If we were using the Settings API as it was intended we would use 171 | * do_settings_sections here. But as we don't want the settings wrapped in a table, 172 | * we'll call our own custom optionsframework_fields. See options-interface.php 173 | * for specifics on how each individual field is generated. 174 | * 175 | * Nonces are provided using the settings_fields() 176 | * 177 | * @since 1.7.0 178 | */ 179 | function options_page() { ?> 180 | 181 |
182 | 183 | menu_settings(); ?> 184 |

185 | 186 | 189 | 190 | 191 | 192 |
193 |
194 |
195 | 196 | 197 |
198 | 199 | 200 |
201 |
202 |
203 |
204 |
205 | 206 |
207 | 208 | get_default_values(); 232 | } 233 | 234 | /* 235 | * Update Settings 236 | * 237 | * This used to check for $_POST['update'], but has been updated 238 | * to be compatible with the theme customizer introduced in WordPress 3.4 239 | */ 240 | 241 | $clean = array(); 242 | $options = & Options_Framework::_optionsframework_options(); 243 | foreach ( $options as $option ) { 244 | 245 | if ( ! isset( $option['id'] ) ) { 246 | continue; 247 | } 248 | 249 | if ( ! isset( $option['type'] ) ) { 250 | continue; 251 | } 252 | 253 | $id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) ); 254 | 255 | // Set checkbox to false if it wasn't sent in the $_POST 256 | if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) { 257 | $input[$id] = false; 258 | } 259 | 260 | // Set each item in the multicheck to false if it wasn't sent in the $_POST 261 | if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) { 262 | foreach ( $option['options'] as $key => $value ) { 263 | $input[$id][$key] = false; 264 | } 265 | } 266 | 267 | // For a value to be submitted to database it must pass through a sanitization filter 268 | if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { 269 | $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option ); 270 | } 271 | } 272 | 273 | // Hook to run after validation 274 | do_action( 'optionsframework_after_validate', $clean ); 275 | 276 | return $clean; 277 | } 278 | 279 | /** 280 | * Display message when options have been saved 281 | */ 282 | 283 | function save_options_notice() { 284 | add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'textdomain' ), 'updated fade' ); 285 | } 286 | 287 | /** 288 | * Get the default values for all the theme options 289 | * 290 | * Get an array of all default values as set in 291 | * options.php. The 'id','std' and 'type' keys need 292 | * to be defined in the configuration array. In the 293 | * event that these keys are not present the option 294 | * will not be included in this function's output. 295 | * 296 | * @return array Re-keyed options configuration array. 297 | * 298 | */ 299 | function get_default_values() { 300 | $output = array(); 301 | $config = & Options_Framework::_optionsframework_options(); 302 | foreach ( (array) $config as $option ) { 303 | if ( ! isset( $option['id'] ) ) { 304 | continue; 305 | } 306 | if ( ! isset( $option['std'] ) ) { 307 | continue; 308 | } 309 | if ( ! isset( $option['type'] ) ) { 310 | continue; 311 | } 312 | if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { 313 | $output[$option['id']] = apply_filters( 'of_sanitize_' . $option['type'], $option['std'], $option ); 314 | } 315 | } 316 | return $output; 317 | } 318 | 319 | /** 320 | * Add options menu item to admin bar 321 | */ 322 | 323 | function optionsframework_admin_bar() { 324 | 325 | $menu = $this->menu_settings(); 326 | 327 | global $wp_admin_bar; 328 | 329 | if ( 'menu' == $menu['mode'] ) { 330 | $href = admin_url( 'admin.php?page=' . $menu['menu_slug'] ); 331 | } else { 332 | $href = admin_url( 'themes.php?page=' . $menu['menu_slug'] ); 333 | } 334 | 335 | $args = array( 336 | 'parent' => 'appearance', 337 | 'id' => 'of_theme_options', 338 | 'title' => $menu['menu_title'], 339 | 'href' => $href 340 | ); 341 | 342 | $wp_admin_bar->add_menu( apply_filters( 'optionsframework_admin_bar', $args ) ); 343 | } 344 | 345 | } -------------------------------------------------------------------------------- /inc/includes/class-options-framework.php: -------------------------------------------------------------------------------- 1 | 5 | * @license GPL-2.0+ 6 | * @link http://wptheming.com 7 | * @copyright 2010-2014 WP Theming 8 | */ 9 | 10 | class Options_Framework { 11 | 12 | /** 13 | * Plugin version, used for cache-busting of style and script file references. 14 | * 15 | * @since 1.7.0 16 | * @type string 17 | */ 18 | const VERSION = '1.9.0'; 19 | 20 | /** 21 | * Gets option name 22 | * 23 | * @since 1.9.0 24 | */ 25 | function get_option_name() { 26 | 27 | $name = ''; 28 | 29 | // Gets option name as defined in the theme 30 | if ( function_exists( 'optionsframework_option_name' ) ) { 31 | $name = optionsframework_option_name(); 32 | } 33 | 34 | // Fallback 35 | if ( '' == $name ) { 36 | $name = get_option( 'stylesheet' ); 37 | $name = preg_replace( "/\W/", "_", strtolower( $name ) ); 38 | } 39 | 40 | return $name; 41 | 42 | } 43 | 44 | /** 45 | * Wrapper for optionsframework_options() 46 | * 47 | * Allows for manipulating or setting options via 'of_options' filter 48 | * For example: 49 | * 50 | * 51 | * add_filter( 'of_options', function( $options ) { 52 | * $options[] = array( 53 | * 'name' => 'Input Text Mini', 54 | * 'desc' => 'A mini text input field.', 55 | * 'id' => 'example_text_mini', 56 | * 'std' => 'Default', 57 | * 'class' => 'mini', 58 | * 'type' => 'text' 59 | * ); 60 | * 61 | * return $options; 62 | * }); 63 | * 64 | * 65 | * Also allows for setting options via a return statement in the 66 | * options.php file. For example (in options.php): 67 | * 68 | * 69 | * return array(...); 70 | * 71 | * 72 | * @return array (by reference) 73 | */ 74 | static function &_optionsframework_options() { 75 | static $options = null; 76 | 77 | if ( !$options ) { 78 | // Load options from options.php file (if it exists) 79 | $location = apply_filters( 'options_framework_location', array( 'options.php' ) ); 80 | if ( $optionsfile = locate_template( $location ) ) { 81 | $maybe_options = require_once $optionsfile; 82 | if ( is_array( $maybe_options ) ) { 83 | $options = $maybe_options; 84 | } else if ( function_exists( 'optionsframework_options' ) ) { 85 | $options = optionsframework_options(); 86 | } 87 | } 88 | 89 | // Allow setting/manipulating options via filters 90 | $options = apply_filters( 'of_options', $options ); 91 | } 92 | 93 | return $options; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /inc/includes/class-options-interface.php: -------------------------------------------------------------------------------- 1 | 5 | * @license GPL-2.0+ 6 | * @link http://wptheming.com 7 | * @copyright 2010-2014 WP Theming 8 | */ 9 | 10 | class Options_Framework_Interface { 11 | 12 | /** 13 | * Generates the tabs that are used in the options menu 14 | */ 15 | static function optionsframework_tabs() { 16 | $counter = 0; 17 | $options = & Options_Framework::_optionsframework_options(); 18 | $menu = ''; 19 | 20 | foreach ( $options as $value ) { 21 | // Heading for Navigation 22 | if ( $value['type'] == "heading" ) { 23 | $counter++; 24 | $class = ''; 25 | $class = ! empty( $value['id'] ) ? $value['id'] : $value['name']; 26 | $class = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower($class) ) . '-tab'; 27 | $menu .= '
' . esc_html( $value['name'] ) . ''; 28 | } 29 | } 30 | 31 | return $menu; 32 | } 33 | 34 | /** 35 | * Generates the options fields that are used in the form. 36 | */ 37 | static function optionsframework_fields() { 38 | 39 | global $allowedtags; 40 | 41 | $options_framework = new Options_Framework; 42 | $option_name = $options_framework->get_option_name(); 43 | $settings = get_option( $option_name ); 44 | $options = & Options_Framework::_optionsframework_options(); 45 | 46 | $counter = 0; 47 | $menu = ''; 48 | 49 | foreach ( $options as $value ) { 50 | 51 | $val = ''; 52 | $select_value = ''; 53 | $output = ''; 54 | 55 | // Wrap all options 56 | if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { 57 | 58 | // Keep all ids lowercase with no spaces 59 | $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) ); 60 | 61 | $id = 'section-' . $value['id']; 62 | 63 | $class = 'section'; 64 | if ( isset( $value['type'] ) ) { 65 | $class .= ' section-' . $value['type']; 66 | } 67 | if ( isset( $value['class'] ) ) { 68 | $class .= ' ' . $value['class']; 69 | } 70 | 71 | $output .= '
'."\n"; 72 | if ( isset( $value['name'] ) ) { 73 | $output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; 74 | } 75 | if ( $value['type'] != 'editor' ) { 76 | $output .= '
' . "\n" . '
' . "\n"; 77 | } 78 | else { 79 | $output .= '
' . "\n" . '
' . "\n"; 80 | } 81 | } 82 | 83 | // Set default value to $val 84 | if ( isset( $value['std'] ) ) { 85 | $val = $value['std']; 86 | } 87 | 88 | // If the option is already saved, override $val 89 | if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) { 90 | if ( isset( $settings[($value['id'])]) ) { 91 | $val = $settings[($value['id'])]; 92 | // Striping slashes of non-array options 93 | if ( !is_array($val) ) { 94 | $val = stripslashes( $val ); 95 | } 96 | } 97 | } 98 | 99 | // If there is a description save it for labels 100 | $explain_value = ''; 101 | if ( isset( $value['desc'] ) ) { 102 | $explain_value = $value['desc']; 103 | } 104 | 105 | // Set the placeholder if one exists 106 | $placeholder = ''; 107 | if ( isset( $value['placeholder'] ) ) { 108 | $placeholder = ' placeholder="' . esc_attr( $value['placeholder'] ) . '"'; 109 | } 110 | 111 | if ( has_filter( 'optionsframework_' . $value['type'] ) ) { 112 | $output .= apply_filters( 'optionsframework_' . $value['type'], $option_name, $value, $val ); 113 | } 114 | 115 | 116 | switch ( $value['type'] ) { 117 | 118 | // Basic text input 119 | case 'text': 120 | $output .= ''; 121 | break; 122 | 123 | // Password input 124 | case 'password': 125 | $output .= ''; 126 | break; 127 | 128 | // Textarea 129 | case 'textarea': 130 | $rows = '8'; 131 | 132 | if ( isset( $value['settings']['rows'] ) ) { 133 | $custom_rows = $value['settings']['rows']; 134 | if ( is_numeric( $custom_rows ) ) { 135 | $rows = $custom_rows; 136 | } 137 | } 138 | 139 | $val = stripslashes( $val ); 140 | $output .= ''; 141 | break; 142 | 143 | // Select Box 144 | case 'select': 145 | $output .= ''; 151 | break; 152 | 153 | 154 | // Radio Box 155 | case "radio": 156 | $name = $option_name .'['. $value['id'] .']'; 157 | foreach ($value['options'] as $key => $option) { 158 | $id = $option_name . '-' . $value['id'] .'-'. $key; 159 | $output .= ''; 160 | } 161 | break; 162 | 163 | // Image Selectors 164 | case "images": 165 | $name = $option_name .'['. $value['id'] .']'; 166 | foreach ( $value['options'] as $key => $option ) { 167 | $selected = ''; 168 | if ( $val != '' && ($val == $key) ) { 169 | $selected = ' of-radio-img-selected'; 170 | } 171 | $output .= ''; 172 | $output .= '
' . esc_html( $key ) . '
'; 173 | $output .= '' . $option .''; 174 | } 175 | break; 176 | 177 | // Checkbox 178 | case "checkbox": 179 | $output .= ''; 180 | $output .= ''; 181 | break; 182 | 183 | // Multicheck 184 | case "multicheck": 185 | foreach ($value['options'] as $key => $option) { 186 | $checked = ''; 187 | $label = $option; 188 | $option = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($key)); 189 | 190 | $id = $option_name . '-' . $value['id'] . '-'. $option; 191 | $name = $option_name . '[' . $value['id'] . '][' . $option .']'; 192 | 193 | if ( isset($val[$option]) ) { 194 | $checked = checked($val[$option], 1, false); 195 | } 196 | 197 | $output .= ''; 198 | } 199 | break; 200 | 201 | // Color picker 202 | case "color": 203 | $default_color = ''; 204 | if ( isset($value['std']) ) { 205 | if ( $val != $value['std'] ) 206 | $default_color = ' data-default-color="' .$value['std'] . '" '; 207 | } 208 | $output .= ''; 209 | 210 | break; 211 | 212 | // Uploader 213 | case "upload": 214 | $output .= Options_Framework_Media_Uploader::optionsframework_uploader( $value['id'], $val, null ); 215 | 216 | break; 217 | 218 | // Typography 219 | case 'typography': 220 | 221 | unset( $font_size, $font_style, $font_face, $font_color ); 222 | 223 | $typography_defaults = array( 224 | 'size' => '', 225 | 'face' => '', 226 | 'style' => '', 227 | 'color' => '' 228 | ); 229 | 230 | $typography_stored = wp_parse_args( $val, $typography_defaults ); 231 | 232 | $typography_options = array( 233 | 'sizes' => of_recognized_font_sizes(), 234 | 'faces' => of_recognized_font_faces(), 235 | 'styles' => of_recognized_font_styles(), 236 | 'color' => true 237 | ); 238 | 239 | if ( isset( $value['options'] ) ) { 240 | $typography_options = wp_parse_args( $value['options'], $typography_options ); 241 | } 242 | 243 | // Font Size 244 | if ( $typography_options['sizes'] ) { 245 | $font_size = ''; 252 | } 253 | 254 | // Font Face 255 | if ( $typography_options['faces'] ) { 256 | $font_face = ''; 262 | } 263 | 264 | // Font Styles 265 | if ( $typography_options['styles'] ) { 266 | $font_style = ''; 272 | } 273 | 274 | // Font Color 275 | if ( $typography_options['color'] ) { 276 | $default_color = ''; 277 | if ( isset($value['std']['color']) ) { 278 | if ( $val != $value['std']['color'] ) 279 | $default_color = ' data-default-color="' .$value['std']['color'] . '" '; 280 | } 281 | $font_color = ''; 282 | } 283 | 284 | // Allow modification/injection of typography fields 285 | $typography_fields = compact( 'font_size', 'font_face', 'font_style', 'font_color' ); 286 | $typography_fields = apply_filters( 'of_typography_fields', $typography_fields, $typography_stored, $option_name, $value ); 287 | $output .= implode( '', $typography_fields ); 288 | 289 | break; 290 | 291 | // Background 292 | case 'background': 293 | 294 | $background = $val; 295 | 296 | // Background Color 297 | $default_color = ''; 298 | if ( isset( $value['std']['color'] ) ) { 299 | if ( $val != $value['std']['color'] ) 300 | $default_color = ' data-default-color="' .$value['std']['color'] . '" '; 301 | } 302 | $output .= ''; 303 | 304 | // Background Image 305 | if ( !isset($background['image']) ) { 306 | $background['image'] = ''; 307 | } 308 | 309 | $output .= Options_Framework_Media_Uploader::optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) ); 310 | 311 | $class = 'of-background-properties'; 312 | if ( '' == $background['image'] ) { 313 | $class .= ' hide'; 314 | } 315 | $output .= '
'; 316 | 317 | // Background Repeat 318 | $output .= ''; 325 | 326 | // Background Position 327 | $output .= ''; 334 | 335 | // Background Attachment 336 | $output .= ''; 343 | $output .= '
'; 344 | 345 | break; 346 | 347 | // Editor 348 | case 'editor': 349 | $output .= '
' . wp_kses( $explain_value, $allowedtags ) . '
'."\n"; 350 | echo $output; 351 | $textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' ); 352 | $default_editor_settings = array( 353 | 'textarea_name' => $textarea_name, 354 | 'media_buttons' => false, 355 | 'tinymce' => array( 'plugins' => 'wordpress' ) 356 | ); 357 | $editor_settings = array(); 358 | if ( isset( $value['settings'] ) ) { 359 | $editor_settings = $value['settings']; 360 | } 361 | $editor_settings = array_merge( $default_editor_settings, $editor_settings ); 362 | wp_editor( $val, $value['id'], $editor_settings ); 363 | $output = ''; 364 | break; 365 | 366 | // Info 367 | case "info": 368 | $id = ''; 369 | $class = 'section'; 370 | if ( isset( $value['id'] ) ) { 371 | $id = 'id="' . esc_attr( $value['id'] ) . '" '; 372 | } 373 | if ( isset( $value['type'] ) ) { 374 | $class .= ' section-' . $value['type']; 375 | } 376 | if ( isset( $value['class'] ) ) { 377 | $class .= ' ' . $value['class']; 378 | } 379 | 380 | $output .= '
' . "\n"; 381 | if ( isset($value['name']) ) { 382 | $output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; 383 | } 384 | if ( isset( $value['desc'] ) ) { 385 | $output .= $value['desc'] . "\n"; 386 | } 387 | $output .= '
' . "\n"; 388 | break; 389 | 390 | // Heading for Navigation 391 | case "heading": 392 | $counter++; 393 | if ( $counter >= 2 ) { 394 | $output .= '
'."\n"; 395 | } 396 | $class = ''; 397 | $class = ! empty( $value['id'] ) ? $value['id'] : $value['name']; 398 | $class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) ); 399 | $output .= '
'; 400 | $output .= '

' . esc_html( $value['name'] ) . '

' . "\n"; 401 | break; 402 | } 403 | 404 | if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { 405 | $output .= '
'; 406 | if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) { 407 | $output .= '
' . wp_kses( $explain_value, $allowedtags) . '
'."\n"; 408 | } 409 | $output .= '
'."\n"; 410 | } 411 | 412 | echo $output; 413 | } 414 | 415 | // Outputs closing div if there tabs 416 | if ( Options_Framework_Interface::optionsframework_tabs() != '' ) { 417 | echo '
'; 418 | } 419 | } 420 | 421 | } -------------------------------------------------------------------------------- /inc/includes/class-options-media-uploader.php: -------------------------------------------------------------------------------- 1 | 5 | * @license GPL-2.0+ 6 | * @link http://wptheming.com 7 | * @copyright 2010-2014 WP Theming 8 | */ 9 | 10 | class Options_Framework_Media_Uploader { 11 | 12 | /** 13 | * Initialize the media uploader class 14 | * 15 | * @since 1.7.0 16 | */ 17 | public function init() { 18 | add_action( 'admin_enqueue_scripts', array( $this, 'optionsframework_media_scripts' ) ); 19 | } 20 | 21 | /** 22 | * Media Uploader Using the WordPress Media Library. 23 | * 24 | * Parameters: 25 | * 26 | * string $_id - A token to identify this field (the name). 27 | * string $_value - The value of the field, if present. 28 | * string $_desc - An optional description of the field. 29 | * 30 | */ 31 | 32 | static function optionsframework_uploader( $_id, $_value, $_desc = '', $_name = '' ) { 33 | 34 | // Gets the unique option id 35 | $options_framework = new Options_Framework; 36 | $option_name = $options_framework->get_option_name(); 37 | 38 | $output = ''; 39 | $id = ''; 40 | $class = ''; 41 | $int = ''; 42 | $value = ''; 43 | $name = ''; 44 | 45 | $id = strip_tags( strtolower( $_id ) ); 46 | 47 | // If a value is passed and we don't have a stored value, use the value that's passed through. 48 | if ( $_value != '' && $value == '' ) { 49 | $value = $_value; 50 | } 51 | 52 | if ($_name != '') { 53 | $name = $_name; 54 | } 55 | else { 56 | $name = $option_name.'['.$id.']'; 57 | } 58 | 59 | if ( $value ) { 60 | $class = ' has-file'; 61 | } 62 | $output .= '' . "\n"; 63 | if ( function_exists( 'wp_enqueue_media' ) ) { 64 | if ( ( $value == '' ) ) { 65 | $output .= '' . "\n"; 66 | } else { 67 | $output .= '' . "\n"; 68 | } 69 | } else { 70 | $output .= '

' . __( 'Upgrade your version of WordPress for full media support.', 'textdomain' ) . '

'; 71 | } 72 | 73 | if ( $_desc != '' ) { 74 | $output .= '' . $_desc . '' . "\n"; 75 | } 76 | 77 | $output .= '
' . "\n"; 78 | 79 | if ( $value != '' ) { 80 | $remove = 'Remove'; 81 | $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value ); 82 | if ( $image ) { 83 | $output .= '' . $remove; 84 | } else { 85 | $parts = explode( "/", $value ); 86 | for( $i = 0; $i < sizeof( $parts ); ++$i ) { 87 | $title = $parts[$i]; 88 | } 89 | 90 | // No output preview if it's not an image. 91 | $output .= ''; 92 | 93 | // Standard generic output if it's not an image. 94 | $title = __( 'View File', 'textdomain' ); 95 | $output .= ''; 96 | } 97 | } 98 | $output .= '
' . "\n"; 99 | return $output; 100 | } 101 | 102 | /** 103 | * Enqueue scripts for file uploader 104 | */ 105 | function optionsframework_media_scripts( $hook ) { 106 | 107 | $menu = Options_Framework_Admin::menu_settings(); 108 | 109 | if ( substr( $hook, -strlen( $menu['menu_slug'] ) ) !== $menu['menu_slug'] ) 110 | return; 111 | 112 | if ( function_exists( 'wp_enqueue_media' ) ) 113 | wp_enqueue_media(); 114 | 115 | wp_register_script( 'of-media-uploader', OPTIONS_FRAMEWORK_DIRECTORY .'js/media-uploader.js', array( 'jquery' ), Options_Framework::VERSION ); 116 | wp_enqueue_script( 'of-media-uploader' ); 117 | wp_localize_script( 'of-media-uploader', 'optionsframework_l10n', array( 118 | 'upload' => __( 'Upload', 'textdomain' ), 119 | 'remove' => __( 'Remove', 'textdomain' ) 120 | ) ); 121 | } 122 | } -------------------------------------------------------------------------------- /inc/includes/class-options-sanitization.php: -------------------------------------------------------------------------------- 1 | 5 | * @license GPL-2.0+ 6 | * @link http://wptheming.com 7 | * @copyright 2010-2014 WP Theming 8 | */ 9 | 10 | /** 11 | * Sanitization for text input 12 | * 13 | * @link http://developer.wordpress.org/reference/functions/sanitize_text_field/ 14 | */ 15 | add_filter( 'of_sanitize_text', 'sanitize_text_field' ); 16 | 17 | /** 18 | * Sanitization for password input 19 | * 20 | * @link http://developer.wordpress.org/reference/functions/sanitize_text_field/ 21 | */ 22 | add_filter( 'of_sanitize_password', 'sanitize_text_field' ); 23 | 24 | /** 25 | * Sanitization for select input 26 | * 27 | * Validates that the selected option is a valid option. 28 | */ 29 | add_filter( 'of_sanitize_select', 'of_sanitize_enum', 10, 2 ); 30 | 31 | /** 32 | * Sanitization for radio input 33 | * 34 | * Validates that the selected option is a valid option. 35 | */ 36 | add_filter( 'of_sanitize_radio', 'of_sanitize_enum', 10, 2 ); 37 | 38 | /** 39 | * Sanitization for image selector 40 | * 41 | * Validates that the selected option is a valid option. 42 | */ 43 | add_filter( 'of_sanitize_images', 'of_sanitize_enum', 10, 2 ); 44 | 45 | /** 46 | * Sanitization for textarea field 47 | * 48 | * @param $input string 49 | * 50 | * @return string $output sanitized string 51 | */ 52 | function of_sanitize_textarea( $input ) { 53 | global $allowedposttags; 54 | 55 | return wp_kses( $input, $allowedposttags); 56 | } 57 | add_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' ); 58 | 59 | /** 60 | * Sanitization for checkbox input 61 | * 62 | * @param $input string (1 or empty) checkbox state 63 | * 64 | * @return bool|string $output '1' or false 65 | */ 66 | function of_sanitize_checkbox( $input ) { 67 | if ( $input ) { 68 | $output = '1'; 69 | } else { 70 | $output = false; 71 | } 72 | return $output; 73 | } 74 | add_filter( 'of_sanitize_checkbox', 'of_sanitize_checkbox' ); 75 | 76 | /** 77 | * Sanitization for multicheck 78 | * 79 | * @param $input 80 | * @param $option 81 | * 82 | * @return string of sanitized values ('1' or false) 83 | */ 84 | function of_sanitize_multicheck( $input, $option ) { 85 | $output = ''; 86 | if ( is_array( $input ) ) { 87 | foreach( $option['options'] as $key => $value ) { 88 | $output[$key] = false; 89 | } 90 | foreach( $input as $key => $value ) { 91 | if ( array_key_exists( $key, $option['options'] ) && $value ) { 92 | $output[$key] = '1'; 93 | } 94 | } 95 | } 96 | return $output; 97 | } 98 | add_filter( 'of_sanitize_multicheck', 'of_sanitize_multicheck', 10, 2 ); 99 | 100 | /** 101 | * File upload sanitization. 102 | * 103 | * Returns a sanitized filepath if it has a valid extension. 104 | * 105 | * @param string $input filepath 106 | * 107 | * @returns string $output filepath 108 | * @return string 109 | */ 110 | function of_sanitize_upload( $input ) { 111 | $output = ''; 112 | $filetype = wp_check_filetype( $input ); 113 | if ( $filetype["ext"] ) { 114 | $output = esc_url( $input ); 115 | } 116 | return $output; 117 | } 118 | add_filter( 'of_sanitize_upload', 'of_sanitize_upload' ); 119 | 120 | /** 121 | * Sanitization for editor input. 122 | * 123 | * Returns unfiltered HTML if user has permissions. 124 | * 125 | * @param string $input 126 | * 127 | * @returns string $output 128 | * @return string 129 | */ 130 | function of_sanitize_editor( $input ) { 131 | if ( current_user_can( 'unfiltered_html' ) ) { 132 | $output = $input; 133 | } 134 | else { 135 | global $allowedtags; 136 | $output = wpautop( wp_kses( $input, $allowedtags ) ); 137 | } 138 | return $output; 139 | } 140 | add_filter( 'of_sanitize_editor', 'of_sanitize_editor' ); 141 | 142 | /** 143 | * Sanitization of input with allowed tags and wpautotop. 144 | * 145 | * Allows allowed tags in html input and ensures tags close properly. 146 | * 147 | * @param string $input 148 | * 149 | * @returns string $output 150 | * @return string 151 | */ 152 | function of_sanitize_allowedtags( $input ) { 153 | global $allowedtags; 154 | 155 | return wpautop( wp_kses( $input, $allowedtags ) ); 156 | } 157 | 158 | /** 159 | * Sanitization of input with allowed post tags and wpautotop. 160 | * 161 | * Allows allowed post tags in html input and ensures tags close properly. 162 | * 163 | * @param string $input 164 | * 165 | * @returns string $output 166 | * @return string 167 | */ 168 | function of_sanitize_allowedposttags( $input ) { 169 | global $allowedposttags; 170 | 171 | return wpautop( wp_kses( $input, $allowedposttags) ); 172 | } 173 | 174 | /** 175 | * Validates that the $input is one of the avilable choices 176 | * for that specific option. 177 | * 178 | * @param string $input 179 | * 180 | * @param $option 181 | * 182 | * @return string 183 | */ 184 | function of_sanitize_enum( $input, $option ) { 185 | $output = ''; 186 | if ( array_key_exists( $input, $option['options'] ) ) { 187 | $output = $input; 188 | } 189 | return $output; 190 | } 191 | 192 | /** 193 | * Sanitization for background option. 194 | * 195 | * @param $input 196 | * 197 | * @return array 198 | */ 199 | function of_sanitize_background( $input ) { 200 | 201 | $output = wp_parse_args( $input, array( 202 | 'color' => '', 203 | 'image' => '', 204 | 'repeat' => 'repeat', 205 | 'position' => 'top center', 206 | 'attachment' => 'scroll' 207 | ) ); 208 | 209 | $output['color'] = apply_filters( 'of_sanitize_hex', $input['color'] ); 210 | $output['image'] = apply_filters( 'of_sanitize_upload', $input['image'] ); 211 | $output['repeat'] = apply_filters( 'of_background_repeat', $input['repeat'] ); 212 | $output['position'] = apply_filters( 'of_background_position', $input['position'] ); 213 | $output['attachment'] = apply_filters( 'of_background_attachment', $input['attachment'] ); 214 | 215 | return $output; 216 | } 217 | add_filter( 'of_sanitize_background', 'of_sanitize_background' ); 218 | 219 | /** 220 | * Sanitization for background repeat 221 | * 222 | * @param $value 223 | * 224 | * @return mixed|void 225 | */ 226 | function of_sanitize_background_repeat( $value ) { 227 | $recognized = of_recognized_background_repeat(); 228 | if ( array_key_exists( $value, $recognized ) ) { 229 | return $value; 230 | } 231 | return apply_filters( 'of_default_background_repeat', current( $recognized ) ); 232 | } 233 | add_filter( 'of_background_repeat', 'of_sanitize_background_repeat' ); 234 | 235 | /** 236 | * Sanitization for background position 237 | * 238 | * @param $value 239 | * 240 | * @return mixed|void 241 | */ 242 | function of_sanitize_background_position( $value ) { 243 | $recognized = of_recognized_background_position(); 244 | if ( array_key_exists( $value, $recognized ) ) { 245 | return $value; 246 | } 247 | return apply_filters( 'of_default_background_position', current( $recognized ) ); 248 | } 249 | add_filter( 'of_background_position', 'of_sanitize_background_position' ); 250 | 251 | /** 252 | * Sanitization for background attachment 253 | * 254 | * @param $value 255 | * 256 | * @return mixed|void 257 | */ 258 | function of_sanitize_background_attachment( $value ) { 259 | $recognized = of_recognized_background_attachment(); 260 | if ( array_key_exists( $value, $recognized ) ) { 261 | return $value; 262 | } 263 | return apply_filters( 'of_default_background_attachment', current( $recognized ) ); 264 | } 265 | add_filter( 'of_background_attachment', 'of_sanitize_background_attachment' ); 266 | 267 | /** 268 | * Sanitization for typography option. 269 | * 270 | * @param $input 271 | * @param $option 272 | * 273 | * @return array 274 | */ 275 | function of_sanitize_typography( $input, $option ) { 276 | 277 | $output = wp_parse_args( $input, array( 278 | 'size' => '', 279 | 'face' => '', 280 | 'style' => '', 281 | 'color' => '' 282 | ) ); 283 | 284 | if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) { 285 | if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) { 286 | $output['face'] = ''; 287 | } 288 | } 289 | else { 290 | $output['face'] = apply_filters( 'of_font_face', $output['face'] ); 291 | } 292 | 293 | $output['size'] = apply_filters( 'of_font_size', $output['size'] ); 294 | $output['style'] = apply_filters( 'of_font_style', $output['style'] ); 295 | $output['color'] = apply_filters( 'of_sanitize_color', $output['color'] ); 296 | return $output; 297 | } 298 | add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 ); 299 | 300 | /** 301 | * Sanitization for font size 302 | * 303 | * @param $value 304 | * 305 | * @return mixed|void 306 | */ 307 | function of_sanitize_font_size( $value ) { 308 | $recognized = of_recognized_font_sizes(); 309 | $value_check = preg_replace('/px/','', $value); 310 | if ( in_array( (int) $value_check, $recognized ) ) { 311 | return $value; 312 | } 313 | return apply_filters( 'of_default_font_size', $recognized ); 314 | } 315 | add_filter( 'of_font_size', 'of_sanitize_font_size' ); 316 | 317 | /** 318 | * Sanitization for font style 319 | * 320 | * @param $value 321 | * 322 | * @return mixed|void 323 | */ 324 | function of_sanitize_font_style( $value ) { 325 | $recognized = of_recognized_font_styles(); 326 | if ( array_key_exists( $value, $recognized ) ) { 327 | return $value; 328 | } 329 | return apply_filters( 'of_default_font_style', current( $recognized ) ); 330 | } 331 | add_filter( 'of_font_style', 'of_sanitize_font_style' ); 332 | 333 | /** 334 | * Sanitization for font face 335 | * 336 | * @param $value 337 | * 338 | * @return mixed|void 339 | */ 340 | function of_sanitize_font_face( $value ) { 341 | $recognized = of_recognized_font_faces(); 342 | if ( array_key_exists( $value, $recognized ) ) { 343 | return $value; 344 | } 345 | return apply_filters( 'of_default_font_face', current( $recognized ) ); 346 | } 347 | add_filter( 'of_font_face', 'of_sanitize_font_face' ); 348 | 349 | /** 350 | * Get recognized background repeat settings 351 | * 352 | * @return array 353 | */ 354 | function of_recognized_background_repeat() { 355 | $default = array( 356 | 'no-repeat' => __( 'No Repeat', 'options-framework' ), 357 | 'repeat-x' => __( 'Repeat Horizontally', 'options-framework' ), 358 | 'repeat-y' => __( 'Repeat Vertically', 'options-framework' ), 359 | 'repeat' => __( 'Repeat All', 'options-framework' ), 360 | ); 361 | return apply_filters( 'of_recognized_background_repeat', $default ); 362 | } 363 | 364 | /** 365 | * Get recognized background positions 366 | * 367 | * @return array 368 | */ 369 | function of_recognized_background_position() { 370 | $default = array( 371 | 'top left' => __( 'Top Left', 'options-framework' ), 372 | 'top center' => __( 'Top Center', 'options-framework' ), 373 | 'top right' => __( 'Top Right', 'options-framework' ), 374 | 'center left' => __( 'Middle Left', 'options-framework' ), 375 | 'center center' => __( 'Middle Center', 'options-framework' ), 376 | 'center right' => __( 'Middle Right', 'options-framework' ), 377 | 'bottom left' => __( 'Bottom Left', 'options-framework' ), 378 | 'bottom center' => __( 'Bottom Center', 'options-framework' ), 379 | 'bottom right' => __( 'Bottom Right', 'options-framework') 380 | ); 381 | return apply_filters( 'of_recognized_background_position', $default ); 382 | } 383 | 384 | /** 385 | * Get recognized background attachment 386 | * 387 | * @return array 388 | */ 389 | function of_recognized_background_attachment() { 390 | $default = array( 391 | 'scroll' => __( 'Scroll Normally', 'options-framework' ), 392 | 'fixed' => __( 'Fixed in Place', 'options-framework') 393 | ); 394 | return apply_filters( 'of_recognized_background_attachment', $default ); 395 | } 396 | 397 | /** 398 | * Sanitize a color represented in hexidecimal notation. 399 | * 400 | * @param string Color in hexidecimal notation. "#" may or may not be prepended to the string. 401 | * @param string The value that this function should return if it cannot be recognized as a color. 402 | * @return string 403 | */ 404 | 405 | function of_sanitize_hex( $hex, $default = '' ) { 406 | if ( of_validate_hex( $hex ) ) { 407 | return $hex; 408 | } 409 | return $default; 410 | } 411 | add_filter( 'of_sanitize_color', 'of_sanitize_hex' ); 412 | 413 | /** 414 | * Get recognized font sizes. 415 | * 416 | * Returns an indexed array of all recognized font sizes. 417 | * Values are integers and represent a range of sizes from 418 | * smallest to largest. 419 | * 420 | * @return array 421 | */ 422 | 423 | function of_recognized_font_sizes() { 424 | $sizes = range( 9, 71 ); 425 | $sizes = apply_filters( 'of_recognized_font_sizes', $sizes ); 426 | $sizes = array_map( 'absint', $sizes ); 427 | return $sizes; 428 | } 429 | 430 | /** 431 | * Get recognized font faces. 432 | * 433 | * Returns an array of all recognized font faces. 434 | * Keys are intended to be stored in the database 435 | * while values are ready for display in in html. 436 | * 437 | * @return array 438 | */ 439 | function of_recognized_font_faces() { 440 | $default = array( 441 | 'arial' => 'Arial', 442 | 'verdana' => 'Verdana, Geneva', 443 | 'trebuchet' => 'Trebuchet', 444 | 'georgia' => 'Georgia', 445 | 'times' => 'Times New Roman', 446 | 'tahoma' => 'Tahoma, Geneva', 447 | 'palatino' => 'Palatino', 448 | 'helvetica' => 'Helvetica*' 449 | ); 450 | return apply_filters( 'of_recognized_font_faces', $default ); 451 | } 452 | 453 | /** 454 | * Get recognized font styles. 455 | * 456 | * Returns an array of all recognized font styles. 457 | * Keys are intended to be stored in the database 458 | * while values are ready for display in in html. 459 | * 460 | * @return array 461 | */ 462 | function of_recognized_font_styles() { 463 | $default = array( 464 | 'normal' => __( 'Normal', 'options-framework' ), 465 | 'italic' => __( 'Italic', 'options-framework' ), 466 | 'bold' => __( 'Bold', 'options-framework' ), 467 | 'bold italic' => __( 'Bold Italic', 'options-framework' ) 468 | ); 469 | return apply_filters( 'of_recognized_font_styles', $default ); 470 | } 471 | 472 | /** 473 | * Is a given string a color formatted in hexidecimal notation? 474 | * 475 | * @param string Color in hexidecimal notation. "#" may or may not be prepended to the string. 476 | * @return bool 477 | */ 478 | function of_validate_hex( $hex ) { 479 | $hex = trim( $hex ); 480 | /* Strip recognized prefixes. */ 481 | if ( 0 === strpos( $hex, '#' ) ) { 482 | $hex = substr( $hex, 1 ); 483 | } 484 | elseif ( 0 === strpos( $hex, '%23' ) ) { 485 | $hex = substr( $hex, 3 ); 486 | } 487 | /* Regex match. */ 488 | if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) { 489 | return false; 490 | } 491 | else { 492 | return true; 493 | } 494 | } -------------------------------------------------------------------------------- /inc/js/media-uploader.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($){ 2 | 3 | var optionsframework_upload; 4 | var optionsframework_selector; 5 | 6 | function optionsframework_add_file(event, selector) { 7 | 8 | var upload = $(".uploaded-file"), frame; 9 | var $el = $(this); 10 | optionsframework_selector = selector; 11 | 12 | event.preventDefault(); 13 | 14 | // If the media frame already exists, reopen it. 15 | if ( optionsframework_upload ) { 16 | optionsframework_upload.open(); 17 | } else { 18 | // Create the media frame. 19 | optionsframework_upload = wp.media.frames.optionsframework_upload = wp.media({ 20 | // Set the title of the modal. 21 | title: $el.data('choose'), 22 | 23 | // Customize the submit button. 24 | button: { 25 | // Set the text of the button. 26 | text: $el.data('update'), 27 | // Tell the button not to close the modal, since we're 28 | // going to refresh the page when the image is selected. 29 | close: false 30 | } 31 | }); 32 | 33 | // When an image is selected, run a callback. 34 | optionsframework_upload.on( 'select', function() { 35 | // Grab the selected attachment. 36 | var attachment = optionsframework_upload.state().get('selection').first(); 37 | optionsframework_upload.close(); 38 | optionsframework_selector.find('.upload').val(attachment.attributes.url); 39 | if ( attachment.attributes.type == 'image' ) { 40 | optionsframework_selector.find('.screenshot').empty().hide().append('Remove').slideDown('fast'); 41 | } 42 | optionsframework_selector.find('.upload-button').unbind().addClass('remove-file').removeClass('upload-button').val(optionsframework_l10n.remove); 43 | optionsframework_selector.find('.of-background-properties').slideDown(); 44 | optionsframework_selector.find('.remove-image, .remove-file').on('click', function() { 45 | optionsframework_remove_file( $(this).parents('.section') ); 46 | }); 47 | }); 48 | 49 | } 50 | 51 | // Finally, open the modal. 52 | optionsframework_upload.open(); 53 | } 54 | 55 | function optionsframework_remove_file(selector) { 56 | selector.find('.remove-image').hide(); 57 | selector.find('.upload').val(''); 58 | selector.find('.of-background-properties').hide(); 59 | selector.find('.screenshot').slideUp(); 60 | selector.find('.remove-file').unbind().addClass('upload-button').removeClass('remove-file').val(optionsframework_l10n.upload); 61 | // We don't display the upload button if .upload-notice is present 62 | // This means the user doesn't have the WordPress 3.5 Media Library Support 63 | if ( $('.section-upload .upload-notice').length > 0 ) { 64 | $('.upload-button').remove(); 65 | } 66 | selector.find('.upload-button').on('click', function(event) { 67 | optionsframework_add_file(event, $(this).parents('.section')); 68 | }); 69 | } 70 | 71 | $('.remove-image, .remove-file').on('click', function() { 72 | optionsframework_remove_file( $(this).parents('.section') ); 73 | }); 74 | 75 | $('.upload-button').click( function( event ) { 76 | optionsframework_add_file(event, $(this).parents('.section')); 77 | }); 78 | 79 | }); -------------------------------------------------------------------------------- /inc/js/options-custom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom scripts needed for the colorpicker, image button selectors, 3 | * and navigation tabs. 4 | */ 5 | 6 | jQuery(document).ready(function($) { 7 | 8 | // Loads the color pickers 9 | $('.of-color').wpColorPicker(); 10 | 11 | // Image Options 12 | $('.of-radio-img-img').click(function(){ 13 | $(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected'); 14 | $(this).addClass('of-radio-img-selected'); 15 | }); 16 | 17 | $('.of-radio-img-label').hide(); 18 | $('.of-radio-img-img').show(); 19 | $('.of-radio-img-radio').hide(); 20 | 21 | // Loads tabbed sections if they exist 22 | if ( $('.nav-tab-wrapper').length > 0 ) { 23 | options_framework_tabs(); 24 | } 25 | 26 | function options_framework_tabs() { 27 | 28 | var $group = $('.group'), 29 | $navtabs = $('.nav-tab-wrapper a'), 30 | active_tab = ''; 31 | 32 | // Hides all the .group sections to start 33 | $group.hide(); 34 | 35 | // Find if a selected tab is saved in localStorage 36 | if ( typeof(localStorage) != 'undefined' ) { 37 | active_tab = localStorage.getItem('active_tab'); 38 | } 39 | 40 | // If active tab is saved and exists, load it's .group 41 | if ( active_tab != '' && $(active_tab).length ) { 42 | $(active_tab).fadeIn(); 43 | $(active_tab + '-tab').addClass('nav-tab-active'); 44 | } else { 45 | $('.group:first').fadeIn(); 46 | $('.nav-tab-wrapper a:first').addClass('nav-tab-active'); 47 | } 48 | 49 | // Bind tabs clicks 50 | $navtabs.click(function(e) { 51 | 52 | e.preventDefault(); 53 | 54 | // Remove active class from all tabs 55 | $navtabs.removeClass('nav-tab-active'); 56 | 57 | $(this).addClass('nav-tab-active').blur(); 58 | 59 | if (typeof(localStorage) != 'undefined' ) { 60 | localStorage.setItem('active_tab', $(this).attr('href') ); 61 | } 62 | 63 | var selected = $(this).attr('href'); 64 | 65 | $group.hide(); 66 | $(selected).fadeIn(); 67 | 68 | }); 69 | } 70 | 71 | }); -------------------------------------------------------------------------------- /inc/js/rebirth.js: -------------------------------------------------------------------------------- 1 | ! 2 | function (t) { 3 | var e = {}; 4 | 5 | function n(o) { 6 | if (e[o]) return e[o].exports; 7 | var r = e[o] = { 8 | i: o, 9 | l: !1, 10 | exports: {} 11 | }; 12 | return t[o].call(r.exports, r, r.exports, n), r.l = !0, r.exports 13 | } 14 | n.m = t, n.c = e, n.d = function (t, e, o) { 15 | n.o(t, e) || Object.defineProperty(t, e, { 16 | enumerable: !0, 17 | get: o 18 | }) 19 | }, n.r = function (t) { 20 | "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { 21 | value: "Module" 22 | }), Object.defineProperty(t, "__esModule", { 23 | value: !0 24 | }) 25 | }, n.t = function (t, e) { 26 | if (1 & e && (t = n(t)), 8 & e) return t; 27 | if (4 & e && "object" == typeof t && t && t.__esModule) return t; 28 | var o = Object.create(null); 29 | if (n.r(o), Object.defineProperty(o, "default", { 30 | enumerable: !0, 31 | value: t 32 | }), 2 & e && "string" != typeof t) 33 | for (var r in t) n.d(o, r, function (e) { 34 | return t[e] 35 | }.bind(null, r)); 36 | return o 37 | }, n.n = function (t) { 38 | var e = t && t.__esModule ? 39 | function () { 40 | return t. 41 | default 42 | } : function () { 43 | return t 44 | }; 45 | return n.d(e, "a", e), e 46 | }, n.o = function (t, e) { 47 | return Object.prototype.hasOwnProperty.call(t, e) 48 | }, n.p = "", n(n.s = 0) 49 | }([function (t, e, n) { 50 | n(3), t.exports = n(2) 51 | }, function (t, e) { 52 | ! 53 | function (e) { 54 | "use strict"; 55 | var n = Object.prototype, 56 | o = n.hasOwnProperty, 57 | r = "function" == typeof Symbol ? Symbol : {}, 58 | a = r.iterator || "@@iterator", 59 | i = r.asyncIterator || "@@asyncIterator", 60 | c = r.toStringTag || "@@toStringTag", 61 | s = "object" == typeof t, 62 | l = e.regeneratorRuntime; 63 | if (l) s && (t.exports = l); 64 | else { 65 | (l = e.regeneratorRuntime = s ? t.exports : {}).wrap = h; 66 | var u = {}, 67 | d = {}; 68 | d[a] = function () { 69 | return this 70 | }; 71 | var p = Object.getPrototypeOf, 72 | f = p && p(p(C([]))); 73 | f && f !== n && o.call(f, a) && (d = f); 74 | var m = w.prototype = g.prototype = Object.create(d); 75 | y.prototype = m.constructor = w, w.constructor = y, w[c] = y.displayName = "GeneratorFunction", l.isGeneratorFunction = function (t) { 76 | var e = "function" == typeof t && t.constructor; 77 | return !!e && (e === y || "GeneratorFunction" === (e.displayName || e.name)) 78 | }, l.mark = function (t) { 79 | return Object.setPrototypeOf ? Object.setPrototypeOf(t, w) : (t.__proto__ = w, c in t || (t[c] = "GeneratorFunction")), t.prototype = Object.create(m), t 80 | }, l.awrap = function (t) { 81 | return { 82 | __await: t 83 | } 84 | }, b(k.prototype), k.prototype[i] = function () { 85 | return this 86 | }, l.AsyncIterator = k, l.async = function (t, e, n, o) { 87 | var r = new k(h(t, e, n, o)); 88 | return l.isGeneratorFunction(e) ? r : r.next().then((function (t) { 89 | return t.done ? t.value : r.next() 90 | })) 91 | }, b(m), m[c] = "Generator", m[a] = function () { 92 | return this 93 | }, m.toString = function () { 94 | return "[object Generator]" 95 | }, l.keys = function (t) { 96 | var e = []; 97 | for (var n in t) e.push(n); 98 | return e.reverse(), 99 | function n() { 100 | for (; e.length;) { 101 | var o = e.pop(); 102 | if (o in t) return n.value = o, n.done = !1, n 103 | } 104 | return n.done = !0, n 105 | } 106 | }, l.values = C, E.prototype = { 107 | constructor: E, 108 | reset: function (t) { 109 | if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(L), !t) 110 | for (var e in this) "t" === e.charAt(0) && o.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = void 0) 111 | }, 112 | stop: function () { 113 | this.done = !0; 114 | var t = this.tryEntries[0].completion; 115 | if ("throw" === t.type) throw t.arg; 116 | return this.rval 117 | }, 118 | dispatchException: function (t) { 119 | if (this.done) throw t; 120 | var e = this; 121 | 122 | function n(n, o) { 123 | return i.type = "throw", i.arg = t, e.next = n, o && (e.method = "next", e.arg = void 0), !!o 124 | } 125 | for (var r = this.tryEntries.length - 1; r >= 0; --r) { 126 | var a = this.tryEntries[r], 127 | i = a.completion; 128 | if ("root" === a.tryLoc) return n("end"); 129 | if (a.tryLoc <= this.prev) { 130 | var c = o.call(a, "catchLoc"), 131 | s = o.call(a, "finallyLoc"); 132 | if (c && s) { 133 | if (this.prev < a.catchLoc) return n(a.catchLoc, !0); 134 | if (this.prev < a.finallyLoc) return n(a.finallyLoc) 135 | } else if (c) { 136 | if (this.prev < a.catchLoc) return n(a.catchLoc, !0) 137 | } else { 138 | if (!s) throw new Error("try statement without catch or finally"); 139 | if (this.prev < a.finallyLoc) return n(a.finallyLoc) 140 | } 141 | } 142 | } 143 | }, 144 | abrupt: function (t, e) { 145 | for (var n = this.tryEntries.length - 1; n >= 0; --n) { 146 | var r = this.tryEntries[n]; 147 | if (r.tryLoc <= this.prev && o.call(r, "finallyLoc") && this.prev < r.finallyLoc) { 148 | var a = r; 149 | break 150 | } 151 | } 152 | a && ("break" === t || "continue" === t) && a.tryLoc <= e && e <= a.finallyLoc && (a = null); 153 | var i = a ? a.completion : {}; 154 | return i.type = t, i.arg = e, a ? (this.method = "next", this.next = a.finallyLoc, u) : this.complete(i) 155 | }, 156 | complete: function (t, e) { 157 | if ("throw" === t.type) throw t.arg; 158 | return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), u 159 | }, 160 | finish: function (t) { 161 | for (var e = this.tryEntries.length - 1; e >= 0; --e) { 162 | var n = this.tryEntries[e]; 163 | if (n.finallyLoc === t) return this.complete(n.completion, n.afterLoc), L(n), u 164 | } 165 | }, 166 | catch: function (t) { 167 | for (var e = this.tryEntries.length - 1; e >= 0; --e) { 168 | var n = this.tryEntries[e]; 169 | if (n.tryLoc === t) { 170 | var o = n.completion; 171 | if ("throw" === o.type) { 172 | var r = o.arg; 173 | L(n) 174 | } 175 | return r 176 | } 177 | } 178 | throw new Error("illegal catch attempt") 179 | }, 180 | delegateYield: function (t, e, n) { 181 | return this.delegate = { 182 | iterator: C(t), 183 | resultName: e, 184 | nextLoc: n 185 | }, "next" === this.method && (this.arg = void 0), u 186 | } 187 | } 188 | } 189 | 190 | function h(t, e, n, o) { 191 | var r = e && e.prototype instanceof g ? e : g, 192 | a = Object.create(r.prototype), 193 | i = new E(o || []); 194 | return a._invoke = function (t, e, n) { 195 | var o = "suspendedStart"; 196 | return function (r, a) { 197 | if ("executing" === o) throw new Error("Generator is already running"); 198 | if ("completed" === o) { 199 | if ("throw" === r) throw a; 200 | return T() 201 | } 202 | for (n.method = r, n.arg = a;;) { 203 | var i = n.delegate; 204 | if (i) { 205 | var c = x(i, n); 206 | if (c) { 207 | if (c === u) continue; 208 | return c 209 | } 210 | } 211 | if ("next" === n.method) n.sent = n._sent = n.arg; 212 | else if ("throw" === n.method) { 213 | if ("suspendedStart" === o) throw o = "completed", n.arg; 214 | n.dispatchException(n.arg) 215 | } else "return" === n.method && n.abrupt("return", n.arg); 216 | o = "executing"; 217 | var s = v(t, e, n); 218 | if ("normal" === s.type) { 219 | if (o = n.done ? "completed" : "suspendedYield", s.arg === u) continue; 220 | return { 221 | value: s.arg, 222 | done: n.done 223 | } 224 | } 225 | "throw" === s.type && (o = "completed", n.method = "throw", n.arg = s.arg) 226 | } 227 | } 228 | }(t, n, i), a 229 | } 230 | 231 | function v(t, e, n) { 232 | try { 233 | return { 234 | type: "normal", 235 | arg: t.call(e, n) 236 | } 237 | } catch (t) { 238 | return { 239 | type: "throw", 240 | arg: t 241 | } 242 | } 243 | } 244 | 245 | function g() {} 246 | 247 | function y() {} 248 | 249 | function w() {} 250 | 251 | function b(t) { 252 | ["next", "throw", "return"].forEach((function (e) { 253 | t[e] = function (t) { 254 | return this._invoke(e, t) 255 | } 256 | })) 257 | } 258 | 259 | function k(t) { 260 | var e; 261 | this._invoke = function (n, r) { 262 | function a() { 263 | return new Promise((function (e, a) { 264 | ! 265 | function e(n, r, a, i) { 266 | var c = v(t[n], t, r); 267 | if ("throw" !== c.type) { 268 | var s = c.arg, 269 | l = s.value; 270 | return l && "object" == typeof l && o.call(l, "__await") ? Promise.resolve(l.__await).then((function (t) { 271 | e("next", t, a, i) 272 | }), (function (t) { 273 | e("throw", t, a, i) 274 | })) : Promise.resolve(l).then((function (t) { 275 | s.value = t, a(s) 276 | }), i) 277 | } 278 | i(c.arg) 279 | }(n, r, e, a) 280 | })) 281 | } 282 | return e = e ? e.then(a, a) : a() 283 | } 284 | } 285 | 286 | function x(t, e) { 287 | var n = t.iterator[e.method]; 288 | if (void 0 === n) { 289 | if (e.delegate = null, "throw" === e.method) { 290 | if (t.iterator.return && (e.method = "return", e.arg = void 0, x(t, e), "throw" === e.method)) return u; 291 | e.method = "throw", e.arg = new TypeError("The iterator does not provide a 'throw' method") 292 | } 293 | return u 294 | } 295 | var o = v(n, t.iterator, e.arg); 296 | if ("throw" === o.type) return e.method = "throw", e.arg = o.arg, e.delegate = null, u; 297 | var r = o.arg; 298 | return r ? r.done ? (e[t.resultName] = r.value, e.next = t.nextLoc, "return" !== e.method && (e.method = "next", e.arg = void 0), e.delegate = null, u) : r : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, u) 299 | } 300 | 301 | function j(t) { 302 | var e = { 303 | tryLoc: t[0] 304 | }; 305 | 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e) 306 | } 307 | 308 | function L(t) { 309 | var e = t.completion || {}; 310 | e.type = "normal", delete e.arg, t.completion = e 311 | } 312 | 313 | function E(t) { 314 | this.tryEntries = [{ 315 | tryLoc: "root" 316 | }], t.forEach(j, this), this.reset(!0) 317 | } 318 | 319 | function C(t) { 320 | if (t) { 321 | var e = t[a]; 322 | if (e) return e.call(t); 323 | if ("function" == typeof t.next) return t; 324 | if (!isNaN(t.length)) { 325 | var n = -1, 326 | r = function e() { 327 | for (; ++n < t.length;) 328 | if (o.call(t, n)) return e.value = t[n], e.done = !1, e; 329 | return e.value = void 0, e.done = !0, e 330 | }; 331 | return r.next = r 332 | } 333 | } 334 | return { 335 | next: T 336 | } 337 | } 338 | 339 | function T() { 340 | return { 341 | value: void 0, 342 | done: !0 343 | } 344 | } 345 | }(function () { 346 | return this 347 | }() || Function("return this")()) 348 | }, function (t, e) {}, function (t, e, n) { 349 | "use strict"; 350 | n.r(e); 351 | n(1); 352 | var o, r = function (t) { 353 | t(".site-wrapper").toggleClass("toggled"), t(event.currentTarget).hide(250), t("body").addClass("overflow-hidden").append(''), t(".sidebar-container").addClass("boxshadow-right") 354 | }, 355 | a = function (t) { 356 | t(".site-wrapper").toggleClass("toggled"), t(".sidebar-toggler").show(250), t("body").removeClass("overflow-hidden"), t(".sidebar-container").removeClass("boxshadow-right"), t(".global-modal").remove() 357 | }, 358 | i = (window, (o = window.jQuery)(".sidebar-toggler").click((function (t) { 359 | r(o), o(".global-modal-click-close").bind("click", (function (t) { 360 | a(o) 361 | })) 362 | })), o(".sidebar-close").click((function (t) { 363 | a(o), o(".global-modal-click-close").unbind() 364 | })), function (t, e) { 365 | e(".click-search").click((function (t) { 366 | e("body").addClass("overflow-hidden").append(''), e(".search-wrapper").show(250) 367 | })), e(".click-search-close").click((function (t) { 368 | e("body").removeClass("overflow-hidden"), e(".search-wrapper").hide(250), e(".global-modal-pc-search").remove() 369 | })) 370 | }(window, window.jQuery), function (t) { 371 | return t(document).scrollTop() <= 0 372 | }), 373 | c = function (t) { 374 | t(".main-header").addClass("top-nav") 375 | }, 376 | s = function (t) { 377 | t(".main-header").removeClass("top-nav") 378 | }, 379 | l = function (t) { 380 | var e = t.map((function (t) { 381 | return e = t, new Promise((function (t, n) { 382 | if (null !== document.getElementById(e.id)) return t(e), !1; 383 | var o = document.createElement("script"); 384 | o.id = e.id, o.addEventListener("load", (function () { 385 | t(e) 386 | }), !1), o.addEventListener("error", (function () { 387 | n(e) 388 | }), !1), o.src = e.url, (document.getElementsByTagName("body")[0] || document.getElementsByTagName("head")[0]).appendChild(o) 389 | })); 390 | var e 391 | })); 392 | return Promise.all(e) 393 | }, 394 | u = function (t) { 395 | var e = t.map((function (t) { 396 | return e = t, new Promise((function (t, n) { 397 | if (null !== document.getElementById(e.id)) return t(e), !1; 398 | var o = document.createElement("link"); 399 | o.type = "text/css", o.rel = "stylesheet", o.id = e.id, o.addEventListener("load", (function () { 400 | t(e) 401 | }), !1), o.addEventListener("error", (function () { 402 | n(e) 403 | }), !1), o.href = e.url, document.getElementsByTagName("head")[0].appendChild(o) 404 | })); 405 | var e 406 | })); 407 | return Promise.all(e) 408 | }; 409 | (function (t, e) { 410 | i(e) ? c(e) : s(e), e(t).scroll((function () { 411 | i(e) ? c(e) : s(e) 412 | })) 413 | })(window, window.jQuery), 414 | function (t) { 415 | (0, t.jQuery)(".site-tooltip").tooltip({ 416 | html: !0, 417 | template: '' 418 | }) 419 | }(window), 420 | function (t) { 421 | (0, t.jQuery)(".site-popover").popover({ 422 | html: !0, 423 | template: '' 424 | }) 425 | }(window), 426 | function (t) { 427 | var e = t.jQuery; 428 | ! 429 | function (t) { 430 | var e = t.jQuery, 431 | n = { 432 | findOrFilter: function (t, e) { 433 | var n = t.find(e); 434 | return t.filter(e).add(n).filter(":not([data-toc-skip])") 435 | }, 436 | generateUniqueIdBase: function (t) { 437 | return e(t).text().trim().replace(/\'/gi, "").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g, "-").replace(/-{2,}/g, "-").substring(0, 64).replace(/^-+|-+$/gm, "").toLowerCase() || t.tagName.toLowerCase() 438 | }, 439 | generateUniqueId: function (t) { 440 | for (var e = this.generateUniqueIdBase(t), n = 0;; n++) { 441 | var o = e; 442 | if (n > 0 && (o += "-" + n), !document.getElementById(o)) return o 443 | } 444 | }, 445 | generateAnchor: function (t) { 446 | if (t.id) return t.id; 447 | var e = this.generateUniqueId(t); 448 | return t.id = e, e 449 | }, 450 | createNavList: function () { 451 | return e('
    ') 452 | }, 453 | createChildNavList: function (t) { 454 | var e = this.createNavList(); 455 | return t.append(e), e 456 | }, 457 | generateNavEl: function (t, n) { 458 | var o = e(''); 459 | o.attr("href", "#" + t), o.text(n); 460 | var r = e("
  • "); 461 | return r.append(o), r 462 | }, 463 | generateNavItem: function (t) { 464 | var n = this.generateAnchor(t), 465 | o = e(t), 466 | r = o.data("toc-text") || o.text(); 467 | return this.generateNavEl(n, r) 468 | }, 469 | getTopLevel: function (t) { 470 | for (var e = 1; e <= 6; e++) { 471 | if (this.findOrFilter(t, "h" + e).length > 1) return e 472 | } 473 | return 1 474 | }, 475 | getHeadings: function (t, e) { 476 | var n = "h" + e, 477 | o = "h" + (e + 1); 478 | return this.findOrFilter(t, n + "," + o) 479 | }, 480 | getNavLevel: function (t) { 481 | return parseInt(t.tagName.charAt(1), 10) 482 | }, 483 | populateNav: function (t, e, n) { 484 | var o, r = t, 485 | a = this; 486 | n.each((function (n, i) { 487 | var c = a.generateNavItem(i); 488 | a.getNavLevel(i) === e ? r = t : o && r === t && (r = a.createChildNavList(o)), r.append(c), o = c 489 | })) 490 | }, 491 | parseOps: function (t) { 492 | var n; 493 | return (n = t.jquery ? { 494 | $nav: t 495 | } : t).$scope = n.$scope || e(document.body), n 496 | } 497 | }, 498 | o = { 499 | $nav: e("nav.article-toc-nav"), 500 | $scope: e("article.article-main") 501 | }; 502 | (o = n.parseOps(o)).$nav.attr("data-toggle", "toc"); 503 | var r = n.createChildNavList(o.$nav), 504 | a = n.getTopLevel(o.$scope), 505 | i = n.getHeadings(o.$scope, a); 506 | n.populateNav(r, a, i) 507 | }(t), e("body").scrollspy({ 508 | target: e(".article-toc-nav"), 509 | offset: 150 510 | }), e("nav.article-toc-nav ul li a").on("click", (function (t) { 511 | e("html, body").animate({ 512 | scrollTop: e(e(this).attr("href")).offset().top - 80 513 | }, 500), t.preventDefault() 514 | })) 515 | }(window), 516 | function (t) { 517 | var e = t.document.querySelector(".article-main"); 518 | if (null === e) return !1; 519 | var n = t.document.querySelector(".reading-progress-bar"); 520 | if (null === n) return !1; 521 | var o = t.document.querySelector(".progress-number"); 522 | t.requestAnimationFrame((function r() { 523 | var a = e.getBoundingClientRect(), 524 | i = t.innerHeight / 2; 525 | if (a.top > i) { 526 | n.setAttribute("aria-valuenow", 0), n.style.width = "0%", o.style.display = "none" 527 | } 528 | if (a.top < i) { 529 | var c = n.getAttribute("aria-valuemax"); 530 | n.setAttribute("aria-valuenow", c), n.style.width = c + "%", o.style.display = "none" 531 | } 532 | if (a.top <= i && a.bottom >= i) { 533 | var s = n.getAttribute("aria-valuemax") * Math.abs(a.top - i) / a.height; 534 | n.setAttribute("aria-valuenow", s), n.style.width = s + "%", o.innerHTML = t.Math.round(s) + "%", o.style.display = "block" 535 | } 536 | t.requestAnimationFrame(r) 537 | })) 538 | }(window); 539 | 540 | function d(t) { 541 | return (d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? 542 | function (t) { 543 | return typeof t 544 | } : function (t) { 545 | return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t 546 | })(t) 547 | } 548 | 549 | function p(t, e) { 550 | if (0 === arguments.length) return null; 551 | var n, o = e || "{y}-{m}-{d} {h}:{i}:{s}"; 552 | "object" === d(t) ? n = t : ("string" == typeof t && /^[0-9]+$/.test(t) && (t = parseInt(t)), "number" == typeof t && 10 === t.toString().length && (t *= 1e3), n = new Date(t)); 553 | var r = { 554 | y: n.getFullYear(), 555 | m: n.getMonth() + 1, 556 | d: n.getDate(), 557 | h: n.getHours(), 558 | i: n.getMinutes(), 559 | s: n.getSeconds(), 560 | a: n.getDay() 561 | }; 562 | return o.replace(/{([ymdhisa])+}/g, (function (t, e) { 563 | var n = r[e]; 564 | return "a" === e ? ["日", "一", "二", "三", "四", "五", "六"][n] : n.toString().padStart(2, "0") 565 | })) 566 | } 567 | 568 | function f(t, e) { 569 | t = 10 === ("" + t).length ? 1e3 * parseInt(t) : +t; 570 | var n = new Date(t), 571 | o = (Date.now() - n) / 1e3; 572 | return o < 30 ? "刚刚" : o < 3600 ? Math.ceil(o / 60) + "分钟前" : o < 86400 ? Math.ceil(o / 3600) + "小时前" : o < 172800 ? "1天前" : e ? p(t, e) : n.getMonth() + 1 + "月" + n.getDate() + "日" + n.getHours() + "时" + n.getMinutes() + "分" 573 | } 574 | var m = function (t, e) { 575 | var n = (new Date).valueOf(), 576 | o = void 0 === e.id ? console.warn("未填写 Toast 节点ID") : e.id, 577 | r = void 0 === e.content ? console.warn("未填写 Toast 内容") : e.content, 578 | a = void 0 === e.time ? f(new Date) : f(new Date(e.time)), 579 | i = void 0 === e.config ? { 580 | animation: !0, 581 | autohide: !0, 582 | delay: 2500 583 | } : e.config, 584 | c = '\n\n"); 585 | t(".toast-wrapper .toast-wrapper-list").append(c), t("#".concat(o + n)).toast(i).toast("show").on("hidden.bs.toast", (function () { 586 | t(this).remove() 587 | })) 588 | }; 589 | 590 | function h(t, e, n, o, r, a, i) { 591 | try { 592 | var c = t[a](i), 593 | s = c.value 594 | } catch (t) { 595 | return void n(t) 596 | } 597 | c.done ? e(s) : Promise.resolve(s).then(o, r) 598 | } 599 | 600 | function v(t) { 601 | return function () { 602 | var e = this, 603 | n = arguments; 604 | return new Promise((function (o, r) { 605 | var a = t.apply(e, n); 606 | 607 | function i(t) { 608 | h(a, o, r, i, c, "next", t) 609 | } 610 | 611 | function c(t) { 612 | h(a, o, r, i, c, "throw", t) 613 | } 614 | i(void 0) 615 | })) 616 | } 617 | }(function () { 618 | var t = v(regeneratorRuntime.mark((function t(e) { 619 | var n, o; 620 | return regeneratorRuntime.wrap((function (t) { 621 | for (;;) switch (t.prev = t.next) { 622 | case 0: 623 | return n = "https://cdn.jsdelivr.net/npm/prismjs@1.20.0", t.next = 3, e.document.querySelectorAll(".post-content pre>code"); 624 | case 3: 625 | if (0 !== (o = t.sent).length) { 626 | t.next = 6; 627 | break 628 | } 629 | return t.abrupt("return", !1); 630 | case 6: 631 | return t.next = 8, u([{ 632 | id: "prism-line-numbers-css", 633 | url: "".concat(n, "/plugins/line-numbers/prism-line-numbers.min.css") 634 | }, { 635 | id: "prism-toolbar-css", 636 | url: "".concat(n, "/plugins/toolbar/prism-toolbar.min.css") 637 | }]); 638 | case 8: 639 | return t.next = 10, l([{ 640 | id: "prism-core-js", 641 | url: "".concat(n, "/components/prism-core.min.js") 642 | }]).then(v(regeneratorRuntime.mark((function t() { 643 | return regeneratorRuntime.wrap((function (t) { 644 | for (;;) switch (t.prev = t.next) { 645 | case 0: 646 | return t.next = 2, o.forEach((function (t) { 647 | t.parentNode.classList.add("overflow-hidden", "line-numbers"); 648 | var n = e.document.createElement("div"); 649 | n.id = "pre-loading", n.className = "d-flex justify-content-center align-items-center pre-block-loading", n.innerHTML = '
    Loading...
    载入代码中...
    ', t.parentNode.insertBefore(n, t) 650 | })); 651 | case 2: 652 | return t.next = 4, l([{ 653 | id: "prism-autoloader-js", 654 | url: "".concat(n, "/plugins/autoloader/prism-autoloader.min.js") 655 | }, { 656 | id: "prism-prism-toolbar-js", 657 | url: "".concat(n, "/plugins/toolbar/prism-toolbar.min.js") 658 | }, { 659 | id: "prism-line-numbers-js", 660 | url: "".concat(n, "/plugins/line-numbers/prism-line-numbers.min.js") 661 | }]).then(v(regeneratorRuntime.mark((function t() { 662 | return regeneratorRuntime.wrap((function (t) { 663 | for (;;) switch (t.prev = t.next) { 664 | case 0: 665 | return e.Prism.plugins.autoloader.languages_path = "".concat(n, "/components/"), e.Prism.plugins.toolbar.registerButton("show-language", (function (t) { 666 | var e = document.createElement("div"); 667 | return e.className = "show-language", e.innerHTML = ' '.concat(t.language), e 668 | })), e.Prism.plugins.toolbar.registerButton("select-code", (function (t) { 669 | var n = document.createElement("button"); 670 | return n.className = "select-code", n.innerHTML = "复制代码", n.addEventListener("click", (function () { 671 | if (document.body.createTextRange) { 672 | var n = document.body.createTextRange(); 673 | n.moveToElementText(t.element), n.select() 674 | } else if (e.getSelection) { 675 | var o = e.getSelection(), 676 | r = document.createRange(); 677 | r.selectNodeContents(t.element), o.removeAllRanges(), o.addRange(r) 678 | } 679 | m(e.jQuery, { 680 | id: "prism-toast", 681 | content: "请按 Ctrl + C / Command + C 进行复制代码!" 682 | }) 683 | })), n 684 | })), t.next = 5, o.forEach((function (t) { 685 | t.classList.contains("language-html") && (t.classList.remove("language-html"), t.classList.add("language-markup")), e.Prism.highlightAll(), setTimeout((function () { 686 | t.parentNode.classList.remove("overflow-hidden"), e.document.querySelector("#pre-loading").remove() 687 | }), 1e3) 688 | })); 689 | case 5: 690 | case "end": 691 | return t.stop() 692 | } 693 | }), t) 694 | })))); 695 | case 4: 696 | case "end": 697 | return t.stop() 698 | } 699 | }), t) 700 | })))); 701 | case 10: 702 | case "end": 703 | return t.stop() 704 | } 705 | }), t) 706 | }))); 707 | return function (e) { 708 | return t.apply(this, arguments) 709 | } 710 | })()(window); 711 | var g = new Promise((function (t, e) { 712 | l([{ 713 | id: "qrcode-js", 714 | url: "https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js" 715 | }]).then((function (e) { 716 | return t(e) 717 | })). 718 | catch((function (t) { 719 | return e(t) 720 | })) 721 | })), 722 | y = (function (t) { 723 | (0, t.jQuery)(".btn-share-popover").on("shown.bs.popover", (function () { 724 | g.then((function (e) { 725 | new QRCode(document.getElementById("wechat-qr-code-img"), { 726 | text: "".concat(t.location.origin).concat(t.location.pathname), 727 | width: 128, 728 | height: 128, 729 | colorDark: "#000000", 730 | colorLight: "#ffffff", 731 | correctLevel: t.QRCode.CorrectLevel.H 732 | }) 733 | })) 734 | })) 735 | }(window), function (t) { 736 | return t.sessionStorage.colorMode ? t.sessionStorage.colorMode.trim() : getComputedStyle(document.documentElement).getPropertyValue("--color-content").trim() 737 | }); 738 | (function (t, e) { 739 | setTimeout((function () { 740 | "dark" === y(t) ? t.document.documentElement.setAttribute("data-theme", "dark") : t.document.documentElement.setAttribute("data-theme", "light") 741 | }), 0), e(".click-dark").click((function (n) { 742 | "dark" === y(t) ? (t.sessionStorage.setItem("colorMode", "light"), t.document.documentElement.setAttribute("data-theme", "light"), t.document.documentElement.style.setProperty("--color-content", "light")) : (m(e, { 743 | id: "dark-mode-toast", 744 | content: "如果您的系统支持黑暗模式,该功能是无效的!" 745 | }), t.sessionStorage.setItem("colorMode", "dark"), t.document.documentElement.setAttribute("data-theme", "dark"), t.document.documentElement.style.setProperty("--color-content", "dark")) 746 | })) 747 | })(window, window.jQuery), 748 | function (t) { 749 | (function (t) { 750 | return new Promise((function (e, n) { 751 | l([{ 752 | id: "zooming-js", 753 | url: "https://cdn.jsdelivr.net/npm/zooming@2.1.1/build/zooming.min.js" 754 | }]).then((function (n) { 755 | var o = new Zooming; 756 | o.config({ 757 | bgColor: "light" === y(t) ? "#fff" : "#263238", 758 | zIndex: 1040, 759 | scaleBase: 1 760 | }), e(o) 761 | })). 762 | catch((function (t) { 763 | return n(t) 764 | })) 765 | })) 766 | })(t).then((function (t) { 767 | t.listen(".post-content-main article.post-content p img"), t.listen(".post-content-main article.post-content figure.kg-image-card img") 768 | })). 769 | catch((function (t) { 770 | console.warn("Zooming 插件加载失败", t) 771 | })) 772 | }(window), 773 | function (t) { 774 | var e = t.jQuery; 775 | e(t.document).ready((function () { 776 | e("article.post-content li").each((function () { 777 | /\[x]\s/gm.test(this.innerHTML) && (this.innerHTML = this.innerHTML.replace(/\[x]\s/gm, ' '), e(this).parent().addClass("todo-list")), /\[\s]\s/gm.test(this.innerHTML) && (this.innerHTML = this.innerHTML.replace(/\[\s]\s/gm, ' '), e(this).parent().addClass("todo-list")) 778 | })) 779 | })) 780 | }(window), 781 | function (t) { 782 | t.document.querySelectorAll(".post-content table").forEach((function (e) { 783 | var n = t.document.createElement("div"); 784 | n.className = "overflow-x-auto table-area", n.innerHTML = "".concat(e.outerHTML), e.parentNode.insertBefore(n, e), e.remove() 785 | })) 786 | }(window); 787 | 788 | function w(t) { 789 | var e = t(window).width(); 790 | e <= 576 && (t("body").addClass("mobile-content").removeClass("tablet-content", "desktop-content"), t(".post-content").addClass("mobile-content").removeClass("tablet-content", "desktop-content")), e > 576 && e < 1200 && (t("body").addClass("tablet-content").removeClass("mobile-content", "desktop-content"), t(".post-content").addClass("tablet-content").removeClass("mobile-content", "desktop-content")), e >= 1200 && (t("body").addClass("desktop-content").removeClass("tablet-content", "mobile-content"), t(".post-content").addClass("desktop-content").removeClass("tablet-content", "mobile-content")) 791 | } 792 | var b, k, x, j, L, E, C, T, S, N = (b = function () { 793 | w(window.jQuery) 794 | }, k = 100, S = function t() { 795 | var e = +new Date - C; 796 | e < k && e > 0 ? j = setTimeout(t, k - e) : (j = null, x || (T = b.apply(E, L), j || (E = L = null))) 797 | }, function () { 798 | for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n]; 799 | E = this, C = +new Date; 800 | var o = x && !j; 801 | return j || (j = setTimeout(S, k)), o && (T = b.apply(E, e), E = e = null), T 802 | }), 803 | I = (function (t) { 804 | var e = t.jQuery; 805 | w(e), addEventListener("resize", (function (t) { 806 | N(e) 807 | })) 808 | }(window), function (t) { 809 | var e = t.jQuery, 810 | n = e(".click-to-top"); 811 | e(void 0).scrollTop() >= 50 ? n.addClass("bounceInRight").removeClass("bounceOutDown") : n.removeClass("bounceInRight").addClass("bounceOutDown"), e(t).scroll((function () { 812 | e(this).scrollTop() >= 50 ? n.addClass("bounceInRight").removeClass("bounceOutDown") : n.removeClass("bounceInRight").addClass("bounceOutDown") 813 | })), n.click((function () { 814 | e("body, html").animate({ 815 | scrollTop: 0 816 | }, 500) 817 | })) 818 | }(window), function (t, e) { 819 | addEventListener("DOMContentLoaded", (function () { 820 | null === t.localStorage.getItem("system-toast") && m(e, { 821 | id: "system-toast", 822 | content: rebirth_option.toast_content, 823 | time: rebirth_option.toast_time 824 | }), e(".system-toast .close").click((function () { 825 | t.localStorage.setItem("system-toast", !0) 826 | })) 827 | })) 828 | }(window, window.jQuery), function (t, e) { 829 | for (var n = [], o = Math.max(2, t - 2); o <= Math.min(e - 1, t + 2); o++) n.push(o); 830 | return t - 2 > 2 && n.unshift("..."), t + 2 < e - 1 && n.push("..."), n.unshift(1), n.push(e), n 831 | }); 832 | (function () { 833 | var t = window.location.href, 834 | e = document.querySelector(".curr-page"), 835 | n = document.querySelector(".total-pages"); 836 | if (e && n) { 837 | var o = Number.parseInt(e.textContent, 10), 838 | r = Number.parseInt(n.textContent, 10), 839 | a = document.querySelector(".pagination"), 840 | i = document.querySelector(".page-item"); 841 | if (r > 1) { 842 | var c = []; 843 | I(o, r).forEach((function (e) { 844 | var n = t.split("/"); 845 | e === o ? c.push('
  • ' + e + "
  • ") : "number" == typeof e ? ("page" === n[n.length - 3] && (t = t.replace(/\/page\/.*$/, "") + "/"), c.push('
  • ' + e + "
  • ")) : c.push('
  • ...
  • ') 846 | })), null !== i && (1 === o ? i.insertAdjacentHTML("beforebegin", c.join("")) : i.insertAdjacentHTML("afterend", c.join(""))) 847 | } else null != a && (a.style.display = "none") 848 | } 849 | })(), 850 | function (t) { 851 | ! 852 | function (t) { 853 | var e = t.jQuery; 854 | e.ajax({ 855 | method: "GET", 856 | url: "https://v2.jinrishici.com/one.json", 857 | dataType: "json", 858 | data: { 859 | client: "browser-sdk/1.2", 860 | "X-User-Token": "i/wLqcKXpGXairZ6OVsjMnwcfAe4YeGQ" 861 | }, 862 | success: function (t) { 863 | e(".home-sentence").text(t.data.content) 864 | } 865 | }) 866 | }(t) 867 | }(window) 868 | }]); -------------------------------------------------------------------------------- /inc/js/trick.js: -------------------------------------------------------------------------------- 1 | ! 2 | function() { 3 | null !== document.getElementById("vcomments") && new Valine({ 4 | el: "#vcomments", 5 | appId: rebirth_option.valine_appid, 6 | appKey: rebirth_option.valine_appkey, 7 | serverURLs: rebirth_option.valine_serverurls, 8 | avatar: "mm", 9 | visitor: !0, 10 | highlight: !0, 11 | recordIP: !0, 12 | placeholder: "请您理智发言,共建美好社会!", 13 | path: window.location.pathname, 14 | meta: ['nick', 'mail', 'link'], 15 | pageSize: 10, 16 | lang: 'zh-CN', 17 | avatarForce: false 18 | }); 19 | let e = {}, t = $(this).index(), a = rebirth_option.home_url; 20 | 21 | function r(e, t) { 22 | let a = new RegExp(t, "gi"); 23 | return e = e.replace(a, function(e) { 24 | return "" + e + "" 25 | }) 26 | } 27 | $("#ghost-search-field").focus(function() { 28 | e[t] || $.ajax({ 29 | type: "GET", 30 | url: a + "/wp-json/rebirth/v1/cache_search/json", 31 | dataType: "json", 32 | success: function(a) { 33 | e[t] = a 34 | } 35 | }) 36 | }), $("#ghost-search-field").on("input propertychange", function() { 37 | let a = $("#ghost-search-field").val(); 38 | if ("" === a) { 39 | $("#ghost-search-results").html(""); 40 | let e = $(".search-meta").attr("data-no-results-text").replace("[results]", 0); 41 | $(".search-meta").text(e) 42 | } else { 43 | let s = "", n = 0; 44 | $.each(e[t], function(e, t) { 45 | -1 === t.title.toUpperCase().indexOf(a.toUpperCase()) && -1 === t.text.toUpperCase().indexOf(a.toUpperCase()) || (s += 46 | function(e, t, a, s, n) { 47 | let i = e.trim().split(" "), l = t.indexOf(i[i.length - 1]), o = a.indexOf(i[i.length - 1]); 48 | return t = l < 20 ? t.slice(0, 30) : t.slice(l - 10, l + 10), a = o < 40 ? a.slice(0, 70) : a.slice(o - 45, o + 45), '

    ' + (t = r(t, e)) + '

    ' + (a = r(a, e) + "...") + "
    发布日期:" + s + "
    " 49 | }(a, t.title, t.text, t.time, t.link), n++) 50 | }), $("#ghost-search-results").html(s); 51 | let i = $(".search-meta").attr("data-no-results-text").replace("[results]", n); 52 | $(".search-meta").text(i) 53 | } 54 | }) 55 | }(); -------------------------------------------------------------------------------- /inc/options-framework.php: -------------------------------------------------------------------------------- 1 | 7 | * @license GPL-2.0+ 8 | * @link http://wptheming.com 9 | * @copyright 2010-2014 WP Theming 10 | * 11 | * @wordpress-plugin 12 | * Plugin Name: Options Framework 13 | * Plugin URI: http://wptheming.com 14 | * Description: A framework for building theme options. 15 | * Version: 1.9.0 16 | * Author: Devin Price 17 | * Author URI: http://wptheming.com 18 | * License: GPL-2.0+ 19 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 20 | * Text Domain: optionsframework 21 | * Domain Path: /languages 22 | */ 23 | 24 | // If this file is called directly, abort. 25 | if ( ! defined( 'WPINC' ) ) { 26 | die; 27 | } 28 | 29 | // Don't load if optionsframework_init is already defined 30 | if (is_admin() && ! function_exists( 'optionsframework_init' ) ) : 31 | 32 | function optionsframework_init() { 33 | 34 | // If user can't edit theme options, exit 35 | if ( ! current_user_can( 'edit_theme_options' ) ) { 36 | return; 37 | } 38 | 39 | // Loads the required Options Framework classes. 40 | require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework.php'; 41 | require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework-admin.php'; 42 | require plugin_dir_path( __FILE__ ) . 'includes/class-options-interface.php'; 43 | require plugin_dir_path( __FILE__ ) . 'includes/class-options-media-uploader.php'; 44 | require plugin_dir_path( __FILE__ ) . 'includes/class-options-sanitization.php'; 45 | 46 | // Instantiate the options page. 47 | $options_framework_admin = new Options_Framework_Admin; 48 | $options_framework_admin->init(); 49 | 50 | // Instantiate the media uploader class 51 | $options_framework_media_uploader = new Options_Framework_Media_Uploader; 52 | $options_framework_media_uploader->init(); 53 | 54 | } 55 | 56 | add_action( 'init', 'optionsframework_init', 20 ); 57 | 58 | endif; 59 | 60 | 61 | /** 62 | * Helper function to return the theme option value. 63 | * If no value has been saved, it returns $default. 64 | * Needed because options are saved as serialized strings. 65 | * 66 | * Not in a class to support backwards compatibility in themes. 67 | */ 68 | if ( ! function_exists( 'rebirth_option' ) ) : 69 | function rebirth_option( $name, $default = false ) { 70 | 71 | $option_name = ''; 72 | 73 | // Gets option name as defined in the theme 74 | if ( function_exists( 'optionsframework_option_name' ) ) { 75 | $option_name = optionsframework_option_name(); 76 | } 77 | 78 | // Fallback option name 79 | if ( '' == $option_name ) { 80 | $option_name = get_option( 'stylesheet' ); 81 | $option_name = preg_replace( "/\W/", "_", strtolower( $option_name ) ); 82 | } 83 | 84 | // Get option settings from database 85 | $options = get_option( $option_name ); 86 | 87 | // Return specific option 88 | if ( isset( $options[$name] ) ) { 89 | return $options[$name]; 90 | } 91 | 92 | return $default; 93 | } 94 | endif; -------------------------------------------------------------------------------- /inc/trick.php: -------------------------------------------------------------------------------- 1 | 3 | 13 | 10 | 11 | 12 | 13 | 14 |
    15 |
    16 | 17 | 18 | 19 |
    20 | 21 |
    22 | 23 | 24 | -------------------------------------------------------------------------------- /options.php: -------------------------------------------------------------------------------- 1 | cat_ID ] = $category->cat_name; 35 | } 36 | 37 | // 将所有标签(tags)加入数组 38 | $options_tags = array(); 39 | $options_tags_obj = get_tags(); 40 | foreach ( $options_tags_obj as $tag ) { 41 | $options_tags[ $tag->term_id ] = $tag->name; 42 | } 43 | 44 | 45 | // 将所有页面(pages)加入数组 46 | $options_pages = array(); 47 | $options_pages_obj = get_pages( 'sort_column=post_parent,menu_order' ); 48 | $options_pages[''] = 'Select a page:'; 49 | foreach ( $options_pages_obj as $page ) { 50 | $options_pages[ $page->ID ] = $page->post_title; 51 | } 52 | 53 | // 如果使用图片单选按钮, define a directory path 54 | $imagepath = get_template_directory_uri() . '/images/'; 55 | 56 | $options = array(); 57 | 58 | // 基本设置 59 | $options[] = array( 60 | 'name' => '基础设置', 61 | 'type' => 'heading' 62 | ); 63 | 64 | // 站点名称 65 | $options[] = array( 66 | 'name' => '站点名称', 67 | 'desc' => 'Yq\'s Blog', 68 | 'id' => 'site_name', 69 | 'std' => '', 70 | 'type' => 'text' 71 | ); 72 | 73 | // 首页封面图 74 | $options[] = array( 75 | 'name' => '首页封面图', 76 | 'desc' => '填写首页封面图的完整链接', 77 | 'id' => 'home_cover', 78 | 'std' => '', 79 | 'type' => 'text' 80 | ); 81 | 82 | // logo 83 | $options[] = array( 84 | 'name' => 'logo', 85 | 'desc' => '最佳尺寸30px*30px, 建议使用svg。 86 | 为什么推荐使用svg图片', 87 | 'id' => 'site_logo', 88 | 'type' => 'text' 89 | ); 90 | 91 | // favicon图片,填写url或相对WordPress根目录的路径 92 | $options[] = array( 93 | 'name' => '网站图标', 94 | 'desc' => 'favicon图片,填写url或相对WordPress根目录的路径', 95 | 'id' => 'favicon_link', 96 | 'std' => '/favicon.png', 97 | 'type' => 'text' 98 | ); 99 | 100 | // 网站关键词 101 | $options[] = array( 102 | 'name' => '网站首页关键词', 103 | 'desc' => '各关键字间用半角逗号","分割,数量在5个以内最佳。', 104 | 'id' => 'site_meta_keywords', 105 | 'type' => 'text' 106 | ); 107 | 108 | // 网站描述 109 | $options[] = array( 110 | 'name' => '网站首页描述', 111 | 'desc' => '用简洁的文字描述本站点,字数建议在120个字以内。', 112 | 'id' => 'site_meta_description', 113 | 'std' => '', 114 | 'type' => 'text' 115 | ); 116 | 117 | // dns预加载图床 118 | $options[] = array( 119 | 'name' => 'DNS预加载图床', 120 | 'desc' => '输入图床链接, 121 | 不需要输入http(s),直接//domain', 122 | 'id' => 'site_dnsprefetch', 123 | 'std' => '', 124 | 'type' => 'text' 125 | ); 126 | 127 | // 默认没有封面图要展示默认封面图的路径 128 | $options[] = array( 129 | 'name' => '默认封面图路径', 130 | 'desc' => '如果没有设置文章特色图,就会用这里的图片,支持Url 131 | 默认在主题images文件夹下', 132 | 'id' => 'default_img', 133 | 'std' => '/images/post.jpg', 134 | 'type' => 'text' 135 | ); 136 | 137 | // 分类的图片设置 138 | $options[] = array( 139 | 'name' => '分类的图片设置,$是分类的tag_ID,#号里面是图片链接', 140 | 'desc' => '请注意格式,严格的json格式 141 | { 142 | "category_$": "#", 143 | "category_$": "#", 144 | 依次添加... 145 | }', 146 | 'id' => 'site_category_img', 147 | 'std' => '{ 148 | "category_$": "#", 149 | "category_$": "#", 150 | ... 151 | }', 152 | 'type' => 'textarea' 153 | ); 154 | 155 | // ICP备案号 156 | $options[] = array( 157 | 'name' => 'ICP备案号', 158 | 'desc' => '填写你的网站ICP备案号', 159 | 'id' => 'site_icp', 160 | 'type' => 'text' 161 | ); 162 | 163 | // 公安网备案号 164 | $options[] = array( 165 | 'name' => '公安网备案号', 166 | 'desc' => '填写你的网站公安网备案号', 167 | 'id' => 'site_gongan', 168 | 'type' => 'text' 169 | ); 170 | 171 | // 公安网备案跳转地址 172 | $options[] = array( 173 | 'name' => '公安网备案跳转地址', 174 | 'desc' => '输入你的公安网备案跳转地址,方便查看', 175 | 'id' => 'site_gongan_link', 176 | 'type' => 'text' 177 | ); 178 | 179 | // 百度统计代码 180 | $options[] = array( 181 | 'name' => '百度统计代码', 182 | 'desc' => '添加你的百度统计代码', 183 | 'id' => 'site_baidutj_script', 184 | 'type' => 'textarea' 185 | ); 186 | 187 | // 百度统计查询链接 188 | $options[] = array( 189 | 'name' => '百度统计查询链接', 190 | 'desc' => '在页面底部展示百度统计查询链接', 191 | 'id' => 'site_baidutj_link', 192 | 'type' => 'text' 193 | ); 194 | 195 | // 网站右下角文字 196 | $options[] = array( 197 | 'name' => '网站右下角文字', 198 | 'desc' => '网站右下角显示文字', 199 | 'id' => 'site_bottom_right_msg', 200 | 'std' => '只珍朝夕,不负韶华。', 201 | 'type' => 'text' 202 | ); 203 | 204 | // 网站底部导航网址 205 | $options[] = array( 206 | 'name' => '网站底部导航网址,$name是网站标题,$link是对应链接', 207 | 'desc' => '请注意格式,严格的json格式 208 | { 209 | "$name": "$link", 210 | "$name": "$link", 211 | 依次添加... 212 | }', 213 | 'id' => 'site_bottom_nav_info', 214 | 'type' => 'textarea', 215 | 'std' => '{ 216 | "百度": "https://www.baidu.com", 217 | "Yq小站": "https://yqqy.top" 218 | }' 219 | ); 220 | 221 | // 作者信息 222 | $options[] = array( 223 | 'name' => '作者信息', 224 | 'type' => 'heading' 225 | ); 226 | 227 | // 作者 228 | $options[] = array( 229 | 'name' => '作者', 230 | 'desc' => 'Yqchilde', 231 | 'id' => 'author_name', 232 | 'std' => '', 233 | 'type' => 'text' 234 | ); 235 | 236 | // 城市 237 | $options[] = array( 238 | 'name' => '城市', 239 | 'desc' => '写下你的城市,展示在你的作者页', 240 | 'id' => 'author_city', 241 | 'std' => '山西 大同', 242 | 'type' => 'text' 243 | ); 244 | 245 | // 个人头像 246 | $options[] = array( 247 | 'name' => '个人头像', 248 | 'desc' => '最佳尺寸92px*92px,用于在作者页显示', 249 | 'id' => 'author_avatar', 250 | 'type' => 'upload' 251 | ); 252 | 253 | // gravatar头像源 254 | $options[] = array( 255 | 'name' => 'gravatar头像源', 256 | 'desc' => '这里填写你的gravatar头像中文源,默认使用极客族 257 | 不需要写http(s)://', 258 | 'id' => 'gravatar_source', 259 | 'std' => 'sdn.geekzu.org', 260 | 'type' => 'text' 261 | ); 262 | 263 | // 自定义关键词和描述 264 | $options[] = array( 265 | 'name' => '警示语 / 励志铭 / 描述', 266 | 'desc' => '写下一段简洁的文字,展示在你的作者页', 267 | 'id' => 'author_flag', 268 | 'std' => '', 269 | 'type' => 'text' 270 | ); 271 | 272 | // 博客弹窗时间 273 | $options[] = array( 274 | 'name' => '弹窗时间', 275 | 'desc' => '弹窗时间,例如2020-04-07T08:00:00 276 | 注意有个日期和时间中间有个「T」', 277 | 'id' => 'toast_time', 278 | 'type' => 'text' 279 | ); 280 | 281 | // 博客弹窗内容 282 | $options[] = array( 283 | 'name' => '弹窗内容', 284 | 'desc' => '要弹窗的内容', 285 | 'id' => 'toast_content', 286 | 'std' => '欢迎访问个人博客!如果觉得这个弹窗频繁,可以手动叉掉后暂时不会再出现哦!', 287 | 'type' => 'text' 288 | ); 289 | 290 | // 支付宝捐赠二维码 291 | $options[] = array( 292 | 'name' => '支付宝捐赠二维码', 293 | 'desc' => '写下一段简洁的文字,展示在你的作者页', 294 | 'id' => 'donate_alipay', 295 | 'type' => 'upload' 296 | ); 297 | 298 | // 微信捐赠二维码 299 | $options[] = array( 300 | 'name' => '微信捐赠二维码', 301 | 'desc' => '写下一段简洁的文字,展示在你的作者页', 302 | 'id' => 'donate_wxpay', 303 | 'type' => 'upload' 304 | ); 305 | 306 | // 社交网络(不写则不显示) 307 | $options[] = array( 308 | 'name' => '社交网络', 309 | 'type' => 'heading' 310 | ); 311 | 312 | // 腾讯QQ 313 | $options[] = array( 314 | 'name' => '腾讯QQ', 315 | 'desc' => 'tencent://message/?uin={{QQ number}}. 如: tencent://message/?uin=123456', 316 | 'id' => 'author_qq', 317 | 'type' => 'text' 318 | ); 319 | 320 | // 微信 321 | $options[] = array( 322 | 'name' => '微信', 323 | 'desc' => '微信二维码', 324 | 'id' => 'author_wechat', 325 | 'type' => 'upload' 326 | ); 327 | 328 | // 微博 329 | $options[] = array( 330 | 'name' => '微博', 331 | 'desc' => '新浪微博地址', 332 | 'id' => 'author_sina', 333 | 'type' => 'text' 334 | ); 335 | 336 | // github 337 | $options[] = array( 338 | 'name' => 'github', 339 | 'desc' => 'github地址', 340 | 'id' => 'author_github', 341 | 'type' => 'text' 342 | ); 343 | 344 | // telegram 345 | $options[] = array( 346 | 'name' => 'telegram', 347 | 'desc' => 'telegram联系方式', 348 | 'id' => 'author_telegram', 349 | 'type' => 'text' 350 | ); 351 | 352 | // 其他 353 | $options[] = array( 354 | 'name' => '其他', 355 | 'type' => 'heading' 356 | ); 357 | 358 | // 关于 359 | $options[] = array( 360 | 'name' => '关于', 361 | 'desc' => sprintf( 'Theme Rebirth v %s | 主题说明 ', Rebirth_Version ), 362 | 'id' => 'theme_intro', 363 | 'std' => '', 364 | 'type' => 'typography ' 365 | ); 366 | 367 | // 检查更新 368 | $options[] = array( 369 | 'name' => '检查更新', 370 | 'desc' => 'Download the latest version', 371 | 'id' => "theme_version", 372 | 'std' => "tag", 373 | 'type' => "images", 374 | 'options' => array( 375 | 'tag' => 'https://img.shields.io/github/v/release/yqchilde/rebirth.svg?style=flat-square', 376 | 'tag2' => 'https://img.shields.io/github/commits-since/yqchilde/rebirth/' . Rebirth_Version . '?logo=dev&style=flat-square', 377 | ), 378 | ); 379 | 380 | // Valine配置提示 381 | $options[] = array( 382 | 'name' => '主题评论采用第三方Valine系统', 383 | 'desc' => 'Valine文档:https://valine.js.org', 384 | 'type' => 'info' 385 | ); 386 | 387 | // appId 388 | $options[] = array( 389 | 'name' => 'Valine->appId', 390 | 'desc' => '第三方评论Valine的appId', 391 | 'id' => 'valine_appid', 392 | 'type' => 'text' 393 | ); 394 | 395 | // appKey 396 | $options[] = array( 397 | 'name' => 'Valine->appKey', 398 | 'desc' => '第三方评论Valine的appKey', 399 | 'id' => 'valine_appkey', 400 | 'type' => 'text' 401 | ); 402 | 403 | // serverURLs 404 | $options[] = array( 405 | 'name' => 'Valine->serverURLs', 406 | 'desc' => '第三方评论Valine的serverURLs', 407 | 'id' => 'valine_serverurls', 408 | 'type' => 'text' 409 | ); 410 | 411 | return $options; 412 | } -------------------------------------------------------------------------------- /page.php: -------------------------------------------------------------------------------- 1 | 11 |
    12 |
    14 |
    15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /page/page-about.php: -------------------------------------------------------------------------------- 1 | 9 |
    10 | 11 | 36 |
    37 | 38 |
    39 |
    关于本站
    40 |
    41 | Yqchilde / 42 | 43 |
    44 |
    45 |
    46 |
    47 |
    48 |
    49 |
    50 |

    简介

    51 |

    男,98年双鱼座伪文艺程序员,吾辈愚钝身无长物,仅所依凭,唯手熟耳。

    52 |

    职业:Gopher🐒。

    53 |

    爱好:写代码,穷游,逗女友开心。

    54 |

    常用昵称:Yqchilde

    55 |

    Gayhub:https://github.com/yqchilde

    57 |

    有趣的工具

    58 |

    短链生成(t.cn):https://t.cn/A6hvLzaD

    59 |

    科学上✈:https://t.cn/A6h7pEyH

    60 |

    喜欢的话

    61 |

    代码写的越急,程序跑得越慢。—— Roy Carlson

    62 |

    最快的IO就是不IO。—— Nils-Peter Nelson

    63 |

    联系

    64 |

    yqchilde@gmail.com

    65 |

    24小时在线,有事请联系!

    66 |

    声明

    67 |

    本博客所有内容采用知识共享署名-非商业性使用-相同方式共享 68 | 4.0 国际许可协议进行许可

    69 |
    70 |
    71 |
    72 |
    73 | 74 | -------------------------------------------------------------------------------- /page/page-archive.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |
    10 | 11 | 36 |
    37 |
    38 |
    文章归档
    39 |
    40 |
    41 |
    42 |
    43 |
    44 | 94 |
    95 |
    96 | 97 | -------------------------------------------------------------------------------- /page/page-links.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 43 |
    44 |
    45 |
    46 |
    47 |

    您好,我的朋友!

    48 |
    49 | 50 | 51 | 52 |
    53 |

    name ?>

    54 |
    55 |
      56 | term_id ); 57 | foreach ( $items as $v ) : ?> 58 |
    • 59 | 74 |
    • 75 | 76 |
    77 | 78 | 79 |
      80 | 82 |
    • 83 | 98 |
    • 99 | 100 |
    101 | 102 |
    103 |
    104 |
    105 |
    106 | 107 | 108 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yqchilde/rebirth/ff5e3e06019d041fa59e8a633c178953f7a5f701/screenshot.png -------------------------------------------------------------------------------- /sidebar.php: -------------------------------------------------------------------------------- 1 | 53 | -------------------------------------------------------------------------------- /single.php: -------------------------------------------------------------------------------- 1 | 11 |
    12 |
    14 |
    15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tpl/footer/footer-info.php: -------------------------------------------------------------------------------- 1 | 10 | 47 | -------------------------------------------------------------------------------- /tpl/footer/footer-wave.php: -------------------------------------------------------------------------------- 1 | 10 | 23 | -------------------------------------------------------------------------------- /tpl/home/home-hero.php: -------------------------------------------------------------------------------- 1 | 11 | 12 |
    13 | 14 | term_id; ?> 15 | 16 | $v ) : ?> 18 | 19 |
    21 | 22 | 23 | 24 | 25 | 26 | 27 |
    29 | 30 |
    31 | 32 | 33 |
    34 | 头像 37 |
    38 |
    39 |
    40 |
    41 | 42 | 43 | 44 | 45 | 篇文章 46 |
    47 |
    48 | 49 | 54 | 55 | 56 | 57 | 58 | 66 | 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 83 | 84 | 85 | 86 | 87 | 92 | 93 | 94 | 95 |
    96 | 97 | 98 |
    99 | 100 |
    102 |
    103 | 104 |
    105 | 该分类下有 篇文章 106 |
    107 | 108 | 109 |
    110 | name ?> 111 |
    112 | 113 |
    description ?> 115 |
    116 | 117 |
    118 | 该标签下有 count ?> 篇文章 119 |
    120 | 121 | 122 |
    123 |
    124 | 125 |
    126 | 127 |
    -------------------------------------------------------------------------------- /tpl/home/home-pagination.php: -------------------------------------------------------------------------------- 1 | max_num_pages; 15 | } 16 | if ($max_page > 1) { 17 | if (!$paged) { 18 | $paged = 1; 19 | } 20 | } 21 | ?> 22 | 23 |
    24 | 73 |
    74 | -------------------------------------------------------------------------------- /tpl/home/home-search.php: -------------------------------------------------------------------------------- 1 | 10 |
    11 |
    12 | 15 |
    16 |
    17 | 18 | 21 |
    22 |
    有 0 篇文章
    23 |
    24 |
    25 |
    26 |
    27 |
    -------------------------------------------------------------------------------- /tpl/home/home-thumb.php: -------------------------------------------------------------------------------- 1 | ID ), 'large' ); 17 | $post_img = $large_image_url[0]; 18 | } else { 19 | $post_img = getThumbnail(); 20 | } 21 | $the_cat = get_the_category(); 22 | $the_cats = ""; 23 | foreach ( $the_cat as $v ) { 24 | $the_cats .= $v->cat_name . ' '; 25 | } 26 | ?> 27 | 28 | 82 | 10 | 11 |
    12 |
    13 |
    14 | -------------------------------------------------------------------------------- /tpl/home/home-totop.php: -------------------------------------------------------------------------------- 1 | 10 | 11 |
    12 | 13 | 14 |
    15 | -------------------------------------------------------------------------------- /tpl/single/single-content.php: -------------------------------------------------------------------------------- 1 | term_id ) ); 24 | // 判断上一篇文章有没有 25 | if ( get_previous_post() != null ) { 26 | // 上一篇文章分类 27 | $prev_blog_cat = get_category( get_the_category( get_previous_post()->ID )[0]->term_id )->cat_name; 28 | // 上一篇文章链接 29 | $prev_blog_link = get_permalink( get_previous_post()->ID ); 30 | } 31 | // 判断下一篇文章有没有 32 | if ( get_next_post() != null ) { 33 | // 下一篇文章分类 34 | $next_blog_cat = get_category( get_the_category( get_next_post()->ID )[0]->term_id )->cat_name; 35 | // 下一篇文章链接 36 | $next_blog_link = get_permalink( get_next_post()->ID ); 37 | } 38 | 39 | ?> 40 |
    41 |
    42 | 49 |
    50 |
    51 | 52 | 53 |
    54 |
    55 | 58 |
    59 |
    60 |
    61 | 72 | 83 |
    84 |
    85 |
    86 |
    87 |
    88 | 支付宝捐赠 90 |
    请使用支付宝扫一扫进行捐赠
    91 |
    92 |
    93 |
    94 |
    95 | 微信捐赠 97 |
    请使用微信扫一扫进行赞赏
    98 |
    99 |
    100 |
    101 |
    102 |
    103 |
    104 |
      105 |
    • 106 | 文章作者: 107 | 108 |
    • 109 |
    • 110 | 文章链接: 111 | 112 |
    • 113 |
    • 114 | 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 116 | 许可协议,转载请注明出处! 117 |
    • 118 |
    119 | 181 | 320 |
    321 |
    322 |
    323 |
    324 |
    325 | -------------------------------------------------------------------------------- /tpl/single/single-header.php: -------------------------------------------------------------------------------- 1 | ID ), 'large' ); 13 | $post_img = $large_image_url[0]; 14 | } else { 15 | $post_img = getThumbnail(); 16 | } 17 | // 时间 18 | $create_time = get_the_time( 'Y-m-d', $post->ID ); 19 | // 分类 20 | $the_cat = get_the_category(); 21 | $the_cats = ""; 22 | foreach ( $the_cat as $v ) { 23 | $the_cats .= $v->cat_name . ' | '; 24 | } 25 | $the_cats = substr( $the_cats, 0, strlen( $the_cats ) - 2 ); 26 | // 作者 27 | $author = get_the_author(); 28 | // 阅读量 29 | setPostViews( get_the_ID() ); 30 | $read_count = getPostViews( get_the_ID() ); 31 | ?> 32 | 33 |
    34 |
    36 |
    37 |
    38 |
    39 | 40 | / 41 | 42 | / 43 | 44 | / 45 | 46 | 阅读量 47 | 48 | 49 |
    50 |
    51 | 52 |
    53 | 10 |
    11 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
    25 | --------------------------------------------------------------------------------