commit 933e17ccff7063232291e1af15bc104e9973b8ee Author: Mashiro Date: Sat May 26 18:59:29 2018 +0800 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/404.php b/404.php new file mode 100644 index 0000000..cc1cc28 --- /dev/null +++ b/404.php @@ -0,0 +1,59 @@ + +> + + + +<?php global $page, $paged;wp_title( '-', true, 'right' ); +bloginfo( 'name' );$site_description = get_bloginfo( 'description', 'display' ); +if ( $site_description && ( is_home() || is_front_page() ) ) echo " - $site_description";if ( $paged >= 2 || $page >= 2 ) echo ' - ' . sprintf( __( '第 %s 页'), max( $paged, $page ) );?> + + + + + +> +
+
+
+
+ +
+

别急,试试站内搜索?

+

Don't worry, search in site?

+ +
+
+ + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..25e216a --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. \ No newline at end of file diff --git a/QQWry.Dat b/QQWry.Dat new file mode 100644 index 0000000..acd9ca1 Binary files /dev/null and b/QQWry.Dat differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2241a83 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +Sakura🌸: A Wonderful WordPress Theme +=== + +![Sakura](https://view.moezx.cc/images/2018/05/26/sakura.png) + +在 Louie 基于 Fuzzz 的 [Akina](http://www.akina.pw/themeakina) 主题修改的主题 [Siren](https://github.com/louie-senpai/Siren) 基础上三次修改 =.= + +两位前辈做的已经很棒了,或许我所做的只是把他们的代码弄得凌乱不堪吧 :) + +总之呢,现在算是前端入门了吧,打算有空完全自己写个主题,改主题这种事以后也许不会做了吧~ + +主题使用说明见: + +希望你喜欢! diff --git a/archive.php b/archive.php new file mode 100644 index 0000000..b6ee4b5 --- /dev/null +++ b/archive.php @@ -0,0 +1,65 @@ + + +
+
+ + + + + + + + +
+ + + +
+ + + + + +
+ + +
+
+ <?php the_author(); ?> +
+
+

+
+
+
+ +
+
+ + +
+ + +
+ + + + + +
+ + + + + +
+ +
+
- + +
+
+ +
+

Comments |

+
+ + +
    + +
+ + + + + + +
+
+ +
+ + + + + 滴,学生卡 | I\'m not a robot'; + $private_ms = akina_option('open_private_message') ? '' : ''; + $args = array( + 'id_form' => 'commentform', + 'id_submit' => 'submit', + 'title_reply' => '', + 'title_reply_to' => '
' . esc_html__('Leave a Reply to', 'akina') . ' %s' . '
', + 'cancel_reply_link' => esc_html__('Cancel Reply', 'akina'), + 'label_submit' => esc_html__('BiuBiuBiu~', 'akina'), + 'comment_field' => '

Markdown Supported while Forbidden

+
+ +

+ 戳我试试 OωO + 嘿嘿嘿 ヾ(≧∇≦*)ゝ +

+
+ + + + + + +
bilibili~(=・ω・=)Tieba
+
' . push_bili_smilies() . '
+ + +
+ ', + 'comment_notes_after' => '', + 'comment_notes_before' => '', + 'fields' => apply_filters( 'comment_form_default_fields', array( + 'avatar' => '
', + 'author' => + '', + 'email' => + '', + 'url' => + '' . $robot_comments . $private_ms , + 'qq' => + '' + ) + ) + ); + comment_form($args); + } + + ?> + +
+ + +
+ diff --git a/cover/gallary/beyond_by_auroralion-dan5njb.jpg b/cover/gallary/beyond_by_auroralion-dan5njb.jpg new file mode 100644 index 0000000..056d9e1 Binary files /dev/null and b/cover/gallary/beyond_by_auroralion-dan5njb.jpg differ diff --git a/cover/gallary/pixar_up_movie_balloons_desktop_1920x1080_hd-wallpaper-507967.jpg b/cover/gallary/pixar_up_movie_balloons_desktop_1920x1080_hd-wallpaper-507967.jpg new file mode 100644 index 0000000..a7a15b5 Binary files /dev/null and b/cover/gallary/pixar_up_movie_balloons_desktop_1920x1080_hd-wallpaper-507967.jpg differ diff --git a/cover/gallary/海の空(56993195)_by_夏T.jpg b/cover/gallary/海の空(56993195)_by_夏T.jpg new file mode 100644 index 0000000..b6d6b38 Binary files /dev/null and b/cover/gallary/海の空(56993195)_by_夏T.jpg differ diff --git a/cover/index.php b/cover/index.php new file mode 100644 index 0000000..6629d51 --- /dev/null +++ b/cover/index.php @@ -0,0 +1,14 @@ + diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..8f75b62 --- /dev/null +++ b/footer.php @@ -0,0 +1,160 @@ + + + + + +
+
+
+
+
+ +
+ +

+ +
+
+ + +
+
+ + +
+ + 2, 'theme_location' => 'primary', 'container' => false ) ); ?> +
+ + + + + + + +
+ +
+ +
+
+ +   切换主题 | SCHEME TOOL + +
+
+
+
+ +
+
+ + +
+
+ + + + + + + diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..4025c62 --- /dev/null +++ b/functions.php @@ -0,0 +1,1448 @@ + esc_html__( '导航菜单', 'akina' ), + ) ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( 'html5', array( + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ) ); + + /* + * Enable support for Post Formats. + * See https://developer.wordpress.org/themes/functionality/post-formats/ + */ + add_theme_support( 'post-formats', array( + 'aside', + 'image', + 'status', + ) ); + + // Set up the WordPress core custom background feature. + add_theme_support( 'custom-background', apply_filters( 'akina_custom_background_args', array( + 'default-color' => 'ffffff', + 'default-image' => '', + ) ) ); + + add_filter('pre_option_link_manager_enabled','__return_true'); + + // 优化代码 + //去除头部冗余代码 + remove_action('wp_head', 'feed_links_extra', 3); + remove_action('wp_head', 'rsd_link'); + remove_action('wp_head', 'wlwmanifest_link'); + remove_action('wp_head', 'index_rel_link'); + remove_action('wp_head', 'start_post_rel_link', 10, 0); + remove_action('wp_head', 'wp_generator'); + remove_action( 'wp_head', 'wp_generator' ); //隐藏wordpress版本 + remove_filter('the_content', 'wptexturize'); //取消标点符号转义 + + remove_action('rest_api_init', 'wp_oembed_register_route'); + remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); + remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); + remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); + remove_action('wp_head', 'wp_oembed_add_discovery_links'); + remove_action('wp_head', 'wp_oembed_add_host_js'); + remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); + + function coolwp_remove_open_sans_from_wp_core() { + wp_deregister_style( 'open-sans' ); + wp_register_style( 'open-sans', false ); + wp_enqueue_style('open-sans',''); + } + add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' ); + + /** + * Disable the emoji's + */ + function disable_emojis() { + remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); + remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); + remove_action( 'wp_print_styles', 'print_emoji_styles' ); + remove_action( 'admin_print_styles', 'print_emoji_styles' ); + remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); + remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); + remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); + add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); + } + add_action( 'init', 'disable_emojis' ); + + /** + * Filter function used to remove the tinymce emoji plugin. + * + * @param array $plugins + * @return array Difference betwen the two arrays + */ + function disable_emojis_tinymce( $plugins ) { + if ( is_array( $plugins ) ) { + return array_diff( $plugins, array( 'wpemoji' ) ); + } else { + return array(); + } + } + + // 移除菜单冗余代码 + add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); + add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); + add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); + function my_css_attributes_filter($var) { + return is_array($var) ? array_intersect($var, array('current-menu-item','current-post-ancestor','current-menu-ancestor','current-menu-parent')) : ''; + } + +} +endif; +add_action( 'after_setup_theme', 'akina_setup' ); + +function admin_lettering(){ + echo''; +} +add_action('admin_head', 'admin_lettering'); + +/** + * Set the content width in pixels, based on the theme's design and stylesheet. + * + * Priority 0 to make it available to lower priority callbacks. + * + * @global int $content_width + */ +function akina_content_width() { + $GLOBALS['content_width'] = apply_filters( 'akina_content_width', 640 ); +} +add_action( 'after_setup_theme', 'akina_content_width', 0 ); + +/** + * Enqueue scripts and styles. + */ +function sakura_scripts() { + if(akina_option('jsdelivr_cdn_test')){ + wp_enqueue_script( 'js_lab', 'https://pages.shino.cc/cdn/js/lib.js', array(), SAKURA_VERSION, true ); + } else { + wp_enqueue_script( 'js_lab', 'https://cdn.jsdelivr.net/gh/moezx/cdn@' . akina_option('jsdelivr_cdn_version', 'latest') . '/js/lib.min.js', array(), SAKURA_VERSION, true ); + } + wp_enqueue_style( 'saukra_css', get_stylesheet_uri(), array(), SAKURA_VERSION ); + // If you do not like the CDN, uncomment this line, and comment the next line + //wp_enqueue_script( 'app', get_template_directory_uri() . '/js/sakura-app.js', array(), SAKURA_VERSION, true ); + wp_enqueue_script( 'app', 'https://cdn.jsdelivr.net/gh/moezx/cdn@3.3.0/js/other/sakura-app.js', array(), SAKURA_VERSION, true ); + if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { + wp_enqueue_script( 'comment-reply' ); + } + + // 20161116 @Louie + $mv_live = akina_option('focus_mvlive') ? 'open' : 'close'; + $movies = akina_option('focus_amv') ? array('url' => akina_option('amv_url'), 'name' => akina_option('amv_title'), 'live' => $mv_live) : 'close'; + $auto_height = akina_option('focus_height') ? 'fixed' : 'auto'; + $code_lamp = 'close'; + if(wp_is_mobile()) $auto_height = 'fixed'; //拦截移动端 + wp_localize_script( 'app', 'Poi' , array( + 'pjax' => akina_option('poi_pjax'), + 'movies' => $movies, + 'windowheight' => $auto_height, + 'codelamp' => $code_lamp, + 'ajaxurl' => admin_url('admin-ajax.php'), + 'order' => get_option('comment_order'), // ajax comments + 'formpostion' => 'bottom' // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 + )); +} +add_action( 'wp_enqueue_scripts', 'sakura_scripts' ); + +/** + * load .php. + */ +require get_template_directory() .'/inc/decorate.php'; +require get_template_directory() .'/inc/swicher.php'; + +/** + * Custom template tags for this theme. + */ +require get_template_directory() . '/inc/template-tags.php'; + +/** + * Customizer additions. + */ +require get_template_directory() . '/inc/customizer.php'; + +/** + * function update + */ +require get_template_directory() . '/inc/theme_plus.php'; +require get_template_directory() . '/inc/categories-images.php'; + +//Comment Location Start +function convertip($ip) { + $dat_path = dirname(__FILE__).'/QQWry.Dat'; + if(!$fd = @fopen($dat_path, 'rb')){ + return 'IP date file not exists or access denied'; + } + $ip = explode('.', $ip); + $ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3]; + $DataBegin = fread($fd, 4); + $DataEnd = fread($fd, 4); + $ipbegin = implode('', unpack('L', $DataBegin)); + if($ipbegin < 0) $ipbegin += pow(2, 32); + $ipend = implode('', unpack('L', $DataEnd)); + if($ipend < 0) $ipend += pow(2, 32); + $ipAllNum = ($ipend - $ipbegin) / 7 + 1; + $BeginNum = 0; + $EndNum = $ipAllNum; + while($ip1num>$ipNum || $ip2num<$ipNum) { + $Middle= intval(($EndNum + $BeginNum) / 2); + fseek($fd, $ipbegin + 7 * $Middle); + $ipData1 = fread($fd, 4); + if(strlen($ipData1) < 4) { + fclose($fd); + return 'System Error'; + } + $ip1num = implode('', unpack('L', $ipData1)); + if($ip1num < 0) $ip1num += pow(2, 32); + if($ip1num > $ipNum) { + $EndNum = $Middle; + continue; + } + $DataSeek = fread($fd, 3); + if(strlen($DataSeek) < 3) { + fclose($fd); + return 'System Error'; + } + $DataSeek = implode('', unpack('L', $DataSeek.chr(0))); + fseek($fd, $DataSeek); + $ipData2 = fread($fd, 4); + if(strlen($ipData2) < 4) { + fclose($fd); + return 'System Error'; + } + $ip2num = implode('', unpack('L', $ipData2)); + if($ip2num < 0) $ip2num += pow(2, 32); + if($ip2num < $ipNum) { + if($Middle == $BeginNum) { + fclose($fd); + return 'Unknown'; + } + $BeginNum = $Middle; + } + } + $ipFlag = fread($fd, 1); + if($ipFlag == chr(1)) { + $ipSeek = fread($fd, 3); + if(strlen($ipSeek) < 3) { + fclose($fd); + return 'System Error'; + } + $ipSeek = implode('', unpack('L', $ipSeek.chr(0))); + fseek($fd, $ipSeek); + $ipFlag = fread($fd, 1); + } + if($ipFlag == chr(2)) { + $AddrSeek = fread($fd, 3); + if(strlen($AddrSeek) < 3) { + fclose($fd); + return 'System Error'; + } + $ipFlag = fread($fd, 1); + if($ipFlag == chr(2)) { + $AddrSeek2 = fread($fd, 3); + if(strlen($AddrSeek2) < 3) { + fclose($fd); + return 'System Error'; + } + $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); + fseek($fd, $AddrSeek2); + } else { + fseek($fd, -1, SEEK_CUR); + } + while(($char = fread($fd, 1)) != chr(0)) + $ipAddr2 .= $char; + $AddrSeek = implode('', unpack('L', $AddrSeek.chr(0))); + fseek($fd, $AddrSeek); + while(($char = fread($fd, 1)) != chr(0)) + $ipAddr1 .= $char; + } else { + fseek($fd, -1, SEEK_CUR); + while(($char = fread($fd, 1)) != chr(0)) + $ipAddr1 .= $char; + + $ipFlag = fread($fd, 1); + if($ipFlag == chr(2)) { + $AddrSeek2 = fread($fd, 3); + if(strlen($AddrSeek2) < 3) { + fclose($fd); + return 'System Error'; + } + $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); + fseek($fd, $AddrSeek2); + } else { + fseek($fd, -1, SEEK_CUR); + } + while(($char = fread($fd, 1)) != chr(0)){ + $ipAddr2 .= $char; + } + } + fclose($fd); + if(preg_match('/http/i', $ipAddr2)) { + $ipAddr2 = ''; + } + $ipaddr = "$ipAddr1 $ipAddr2"; + $ipaddr = preg_replace('/CZ88.Net/is', '', $ipaddr); + $ipaddr = preg_replace('/^s*/is', '', $ipaddr); + $ipaddr = preg_replace('/s*$/is', '', $ipaddr); + if(preg_match('/http/i', $ipaddr) || $ipaddr == '') { + $ipaddr = 'Unknown'; + } + $ipaddr = iconv('gbk', 'utf-8//IGNORE', $ipaddr); + if( $ipaddr != ' ' ) + return $ipaddr; + else + $ipaddr = '火星来客'; + return $ipaddr; +} +//Comment Location End + +/** + * COMMENT FORMATTING + * + * 标准的 lazyload 输出头像 + * comment_author_email, '80', '', get_comment_author(), array( 'class' => array( 'lazyload' ) ) ) ); ?> + * + * 如果不延时是这样的 + * comment_author_email, '80', '', get_comment_author() ); ?> + * + */ +if(!function_exists('akina_comment_format')){ + function akina_comment_format($comment, $args, $depth){ + $GLOBALS['comment'] = $comment; + ?> +
  • id="comment-"> +
    +
    +
    + +
    +
    + + $depth, 'max_depth' => $args['max_depth']))); ?> +
    +
    comment_agent); ?>comment_agent); ?> 来自: + comment_ID; + $i_private = get_comment_meta($comment_ID, '_private', true); + $flag .= ' 状态: 私密('; + if (!empty($i_private)) { + $flag .= '是 '; + } else { + $flag .= '否 '; + } + $flag .= ')'; + echo $flag; + } ?>
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + get_results( + "SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = '$comment_author_email' ")); + if($author_count>=1 && $author_count< 5 )//数字可自行修改,代表评论次数。 + echo ''; + else if($author_count>=6 && $author_count< 10) + echo ''; + else if($author_count>=11 && $author_count< 20) + echo ''; + else if($author_count>=21 && $author_count< 40) + echo ''; + else if($author_count>=41 && $author_count< 80) + echo ''; + else if($author_count>=81 && $author_count< 160) + echo ''; + else if($author_count>=161) + echo ''; + } + +/** + * post views. + * @bigfa + */ +function restyle_text($number) { + if($number >= 1000) { + return round($number/1000,2) . 'k'; + }else{ + return $number; + } +} + +function set_post_views() { + global $post; + $post_id = intval($post->ID); + $count_key = 'views'; + $views = get_post_custom($post_id); + $views = intval($views['views'][0]); + if(is_single() || is_page()) { + if(!update_post_meta($post_id, 'views', ($views + 1))) { + add_post_meta($post_id, 'views', 1, true); + } + } +} +add_action('get_header', 'set_post_views'); + +function get_post_views($post_id) { + /* 修改需配合统计插件 + * $count_key = 'views'; + * $views = get_post_custom($post_id); + * $views = intval($views['views'][0]); + * $post_views = intval(post_custom('views')); + * if($views == '') { + * return 0; + * }else{ + * return restyle_text($views); + * } + */ + return wp_statistics_pages(total,uri,$post_id); +} + + +/* + * Ajax点赞 + */ +add_action('wp_ajax_nopriv_specs_zan', 'specs_zan'); +add_action('wp_ajax_specs_zan', 'specs_zan'); +function specs_zan(){ + global $wpdb,$post; + $id = $_POST["um_id"]; + $action = $_POST["um_action"]; + if ( $action == 'ding'){ + $specs_raters = get_post_meta($id,'specs_zan',true); + $expire = time() + 99999999; + $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; // make cookies work with localhost + setcookie('specs_zan_'.$id,$id,$expire,'/',$domain,false); + if (!$specs_raters || !is_numeric($specs_raters)) { + update_post_meta($id, 'specs_zan', 1); + } + else { + update_post_meta($id, 'specs_zan', ($specs_raters + 1)); + } + echo get_post_meta($id,'specs_zan',true); + } + die; +} + + +/* + * 友情链接 + */ +function get_the_link_items($id = null){ + $bookmarks = get_bookmarks('orderby=date&category=' .$id ); + $output = ''; + if ( !empty($bookmarks) ) { + $output .= ''; + } + return $output; +} + +function get_link_items(){ + $linkcats = get_terms( 'link_category' ); + if ( !empty($linkcats) ) { + foreach( $linkcats as $linkcat){ + $result .= ''; + if( $linkcat->description ) $result .= ''; + $result .= get_the_link_items($linkcat->term_id); + } + } else { + $result = get_the_link_items(); + } + return $result; +} + + +/* + * Gravatar头像使用中国服务器 + */ +function gravatar_cn( $url ){ + $gravatar_url = array('0.gravatar.com','1.gravatar.com','2.gravatar.com','secure.gravatar.com'); + return str_replace( $gravatar_url, 'gravatar.shino.cc', $url ); +} +add_filter( 'get_avatar_url', 'gravatar_cn', 4 ); + +/* + * 自定义默认头像 + */ +add_filter( 'avatar_defaults', 'mytheme_default_avatar' ); + +function mytheme_default_avatar ( $avatar_defaults ) { + //$new_avatar_url = get_template_directory_uri() . '/images/default_avatar.png'; + $new_avatar_url = 'https://cn.gravatar.com/avatar/b745710ae6b0ce9dfb13f5b7c0956be1'; + $avatar_defaults[$new_avatar_url] = 'Default Avatar'; + return $avatar_defaults; +} + +/* + * 阻止站内文章互相Pingback + */ +function theme_noself_ping( &$links ) { + $home = get_option( 'home' ); + foreach ( $links as $l => $link ) + if ( 0 === strpos( $link, $home ) ) + unset($links[$l]); +} +add_action('pre_ping','theme_noself_ping'); + + +/* + * 订制body类 +*/ +function akina_body_classes( $classes ) { + // Adds a class of group-blog to blogs with more than 1 published author. + if ( is_multi_author() ) { + $classes[] = 'group-blog'; + } + // Adds a class of hfeed to non-singular pages. + if ( ! is_singular() ) { + $classes[] = 'hfeed'; + } + // 定制中文字体class + $classes[] = 'chinese-font'; + /*if(!wp_is_mobile()) { + $classes[] = 'serif'; + }*/ + return $classes; +} +add_filter( 'body_class', 'akina_body_classes' ); + + +/* + * 图片CDN + */ +add_filter( 'upload_dir', 'wpjam_custom_upload_dir' ); +function wpjam_custom_upload_dir( $uploads ) { + $upload_path = ''; + $upload_url_path = akina_option('qiniu_cdn'); + + if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) { + $uploads['basedir'] = WP_CONTENT_DIR . '/uploads'; + } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { + $uploads['basedir'] = path_join( ABSPATH, $upload_path ); + } else { + $uploads['basedir'] = $upload_path; + } + + $uploads['path'] = $uploads['basedir'].$uploads['subdir']; + + if ( $upload_url_path ) { + $uploads['baseurl'] = $upload_url_path; + $uploads['url'] = $uploads['baseurl'].$uploads['subdir']; + } + return $uploads; +} + + +/* + * 删除自带小工具 +*/ +function unregister_default_widgets() { + unregister_widget("WP_Widget_Pages"); + unregister_widget("WP_Widget_Calendar"); + unregister_widget("WP_Widget_Archives"); + unregister_widget("WP_Widget_Links"); + unregister_widget("WP_Widget_Meta"); + unregister_widget("WP_Widget_Search"); + unregister_widget("WP_Widget_Text"); + unregister_widget("WP_Widget_Categories"); + unregister_widget("WP_Widget_Recent_Posts"); + unregister_widget("WP_Widget_Recent_Comments"); + unregister_widget("WP_Widget_RSS"); + unregister_widget("WP_Widget_Tag_Cloud"); + unregister_widget("WP_Nav_Menu_Widget"); +} +add_action("widgets_init", "unregister_default_widgets", 11); + + +/** + * Jetpack setup function. + * + * See: https://jetpack.com/support/infinite-scroll/ + * See: https://jetpack.com/support/responsive-videos/ + */ +function akina_jetpack_setup() { + // Add theme support for Infinite Scroll. + add_theme_support( 'infinite-scroll', array( + 'container' => 'main', + 'render' => 'akina_infinite_scroll_render', + 'footer' => 'page', + ) ); + + // Add theme support for Responsive Videos. + add_theme_support( 'jetpack-responsive-videos' ); +} +add_action( 'after_setup_theme', 'akina_jetpack_setup' ); + +/** + * Custom render function for Infinite Scroll. + */ +function akina_infinite_scroll_render() { + while ( have_posts() ) { + the_post(); + if ( is_search() ) : + get_template_part( 'tpl/content', 'search' ); + else : + get_template_part( 'tpl/content', get_post_format() ); + endif; + } +} + + +/* + * 编辑器增强 + */ +function enable_more_buttons($buttons) { + $buttons[] = 'hr'; + $buttons[] = 'del'; + $buttons[] = 'sub'; + $buttons[] = 'sup'; + $buttons[] = 'fontselect'; + $buttons[] = 'fontsizeselect'; + $buttons[] = 'cleanup'; + $buttons[] = 'styleselect'; + $buttons[] = 'wp_page'; + $buttons[] = 'anchor'; + $buttons[] = 'backcolor'; + return $buttons; +} +add_filter("mce_buttons_3", "enable_more_buttons"); +// 下载按钮 +function download($atts, $content = null) { +return ' +Download';} +add_shortcode("download", "download"); + +add_action('after_wp_tiny_mce', 'bolo_after_wp_tiny_mce'); +function bolo_after_wp_tiny_mce($mce_settings) { +?> + +'."\n"; + echo ''."\n"; + //echo ''."\n"; + echo ''."\n"; +} + +add_action('login_head', 'custom_login'); + +//Login Page Title +function custom_headertitle ( $title ) { + return get_bloginfo('name'); +} +add_filter('login_headertitle','custom_headertitle'); + +//Login Page Link +function custom_loginlogo_url($url) { + return esc_url( home_url('/') ); +} +add_filter( 'login_headerurl', 'custom_loginlogo_url' ); + +//Login Page Footer +function custom_html() { + if ( akina_option('login_bg') ) { + $loginbg = akina_option('login_bg'); + }else{ + $loginbg = get_bloginfo('template_directory').'/images/hd.png'; + } + echo ''."\n"; + echo ''."\n"; + echo ''; + echo ' + '; +} +add_action('login_footer', 'custom_html'); + +//Login message +//* Add custom message to WordPress login page +function smallenvelop_login_message( $message ) { + if ( empty($message) ){ + return '

    You may try 3 times for every 5 minutes!

    '; + } else { + return $message; + } +} +//add_filter( 'login_message', 'smallenvelop_login_message' ); + +//Fix password reset bug +function resetpassword_message_fix( $message ) { + $message = str_replace("<", "", $message); + $message = str_replace(">", "", $message); + return $message; +} +add_filter( 'retrieve_password_message', 'resetpassword_message_fix' ); + +/* + * 评论邮件回复 + */ +function comment_mail_notify($comment_id){ + $mail_user_name = akina_option('mail_user_name') ? akina_option('mail_user_name') : 'poi'; + $comment = get_comment($comment_id); + $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; + $spam_confirmed = $comment->comment_approved; + if(($parent_id != '') && ($spam_confirmed != 'spam')){ + $wp_email = $mail_user_name . '@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); + $to = trim(get_comment($parent_id)->comment_author_email); + $subject = '你在 [' . get_option("blogname") . '] 的留言有了回应'; + $message = ' +
    +
    + +
    +
    +

    Dear ' . trim(get_comment($parent_id)->comment_author) . '

    +
    +

    您有一条来自'. get_option("blogname") .'的回复

    +
    +

    您在文章《' . get_the_title($comment->comment_post_ID) . '》上发表的评论:

    +

    ' + . trim(get_comment($parent_id)->comment_content) . '

    +

    ' . trim($comment->comment_author) . ' 给您的回复如下:

    +

    ' + . trim($comment->comment_content) . '

    + + +

    本邮件为系统自动发出,请勿直接回复
    + © '.date(Y).' '.get_option("blogname").'

    +
    +
    +'; + $message = convert_smilies($message); + $message = str_replace("f(x)=∫(",'emoji',$message); + + $message = str_replace('{UPLOAD}', 'https://i.loli.net/', $message); + $message = str_replace('[/img][img]', '[/img^img]', $message); + + $message = str_replace('[img]', '', $message); + + $message = str_replace('[/img^img]', '" style="width:80%;display: block;margin-left: auto;margin-right: auto;">"; + $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; + wp_mail( $to, $subject, $message, $headers ); + } +} +add_action('comment_post', 'comment_mail_notify'); + +/* + * 链接新窗口打开 + */ +function rt_add_link_target( $content ){ + $content = str_replace(' tag to split into segments + $bits = explode( '$bit ){ + // fix the target="_blank" bug after the link + if ( strpos( $bit, 'href' ) === false ) continue; + // find the end of each link + $pos = strpos( $bit, '>' ); + // check if there is an end (only fails with malformed markup) + if( $pos !== false ){ + // get a string with just the link's attibutes + $part = substr( $bit, 0, $pos ); + // for comparison, get the current site/network url + $siteurl = network_site_url(); + // if the site url is in the attributes, assume it's in the href and skip, also if a target is present + if( strpos( $part, $siteurl ) === false && strpos( $part, 'target=' ) === false ){ + // add the target attribute + $bits[$key] = 'target="_blank" ' . $bits[$key]; + } + } + } + // re-assemble the content, and return it + return implode( '
    ', $content); + $content = str_replace('[/img^img]', '" class="lazyload comment_inline_img" onerror="imgError(this)">'; + } + return $return_smiles; +} + +function smilies_reset() { +global $wpsmiliestrans; +// don't bother setting up smilies if they are disabled +if ( !get_option( 'use_smilies' ) ) + return; + + $wpsmiliestrans = [ + ':good:' => 'icon_good.gif', + ':han:' => 'icon_han.gif', + ':spray:' => 'icon_spray.gif', + ':Grievance:' => 'icon_Grievance.gif', + ':shui:' => 'icon_shui.gif', + ':reluctantly:' => 'icon_reluctantly.gif', + ':anger:' => 'icon_anger.gif', + ':tongue:' => 'icon_tongue.gif', + ':se:' => 'icon_se.gif', + ':haha:' => 'icon_haha.gif', + ':rmb:' => 'icon_rmb.gif', + ':doubt:' => 'icon_doubt.gif', + ':tear:' => 'icon_tear.gif', + ':surprised2:' => 'icon_surprised2.gif', + ':Happy:' => 'icon_Happy.gif', + ':ku:' => 'icon_ku.gif', + ':surprised:' => 'icon_surprised.gif', + ':theblackline:' => 'icon_theblackline.gif', + ':smilingeyes:' => 'icon_smilingeyes.gif', + ':spit:' => 'icon_spit.gif', + ':huaji:' => 'icon_huaji.gif', + ':bbd:' => 'icon_bbd.gif', + ':hu:' => 'icon_hu.gif', + ':shame:' => 'icon_shame.gif', + ':naive:' => 'icon_naive.gif', + ':rbq:' => 'icon_rbq.gif', + ':britan:' => 'icon_britan.gif', + ':aa:' => 'icon_aa.gif', + ':niconiconi:' => 'icon_niconiconi.gif', + ':niconiconi-t:' => 'icon_niconiconi_t.gif', + ':niconiconit:' => 'icon_niconiconit.gif', + ':awesome:' => 'icon_awesome.gif', + ]; +} +smilies_reset(); + +function push_emoji_panel() { + return ' +
    (⌒▽⌒) + ( ̄▽ ̄) + (=・ω・=) + (`・ω・´) + (〜 ̄△ ̄)〜 + (・∀・) + (°∀°)ノ + ( ̄3 ̄) + ╮( ̄▽ ̄)╭ + (´_ゝ`) + ←_← + →_→ + (<_<) + (>_>) + (;¬_¬) + ("▔□▔)/ + (゚Д゚≡゚д゚)!? + Σ(゚д゚;) + Σ( ̄□ ̄||) + (’;ω;‘) + (/TДT)/ + (^・ω・^ ) + (。・ω・。) + (● ̄(エ) ̄●) + ε=ε=(ノ≧∇≦)ノ + (’・_・‘) + (-_-#) + ( ̄へ ̄) + ( ̄ε(# ̄)Σ + ヽ(‘Д’)ノ + (#-_-)┯━┯ + (╯°口°)╯(┴—┴ + ←◡← + ( ♥д♥) + _(:3」∠)_ + Σ>―(〃°ω°〃)♡→ + ⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄ + (╬゚д゚)▄︻┻┳═一 + ・*・:≡( ε:) + (笑) + (汗) + (泣) + (苦笑) + '; +} + +function get_wp_root_path() { + $base = dirname(__FILE__); + $path = false; + + if (@file_exists(dirname(dirname($base)))) + { + $path = dirname(dirname($base)); + } + else + if (@file_exists(dirname(dirname(dirname($base))))) + { + $path = dirname(dirname(dirname($base))); + } + else + $path = false; + + if ($path != false) + { + $path = str_replace("\\", "/", $path); + } + return $path; +} + +// bilibili smiles +$bilismiliestrans = array(); +function push_bili_smilies(){ + global $bilismiliestrans; + $smiles_path = get_wp_root_path(). "/themes/Sakura/images/smilies/bili/"; + $name = array( 'baiyan','fadai','koubi','qinqin','weiqu','bishi','fanu','kun','se','weixiao','bizui','ganga','lengmo','shengbing','wunai','chan','guilian','liubixue','shengqi','xiaoku','daku','guzhang','liuhan','shuizhao','xieyanxiao','dalao','haixiu','liulei','sikao','yiwen','dalian','heirenwenhao','miantian','tiaokan','yun','dianzan','huaixiao','mudengkoudai','tiaopi','zaijian','doge','jingxia','nanguo','touxiao','zhoumei','facai','keai','outu','tuxue','zhuakuang' ); + $return_smiles = ''; + for( $i=0;$i
    '; + // 正文转换 + // Type 1: ' f(x)=∫(xxx)sec²xdx ' + $bilismiliestrans[' f(x)=∫(' . $name[$i] . ')sec²xdx '] = ''; + // Type 2: 'f(x)=∫(xxx)sec²xdx' + $bilismiliestrans['f(x)=∫(' . $name[$i] . ')sec²xdx'] = ''; + // Type 3: '{xxx}' + $bilismiliestrans['{' . $name[$i] . '}'] = ''; + } + return $return_smiles; +} +push_bili_smilies(); + +function bili_smile_filter($content) { + global $bilismiliestrans; + $content = str_replace(array_keys($bilismiliestrans), $bilismiliestrans, $content); + return $content; +} +add_filter('the_content', 'bili_smile_filter'); //替换文章关键词 +add_filter( 'comment_text', 'bili_smile_filter' );//替换评论关键词 + +function featuredtoRSS($content) { + global $post; + if ( has_post_thumbnail( $post->ID ) ){ + $content = '
    ' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '
    ' . $content; + } + return $content; +} +add_filter('the_excerpt_rss', 'featuredtoRSS'); +add_filter('the_content_feed', 'featuredtoRSS'); + +// +function bili_smile_filter_rss($content) { + $content = str_replace("f(x)=∫(",'emoji',$content); + $content = str_replace('[img]', '', $content); + return $content; +} +add_filter( 'comment_text_rss', 'bili_smile_filter_rss' );//替换评论rss关键词 + +function toc_support($content) { + $content = str_replace('[toc]', '
    ', $content); // TOC 支持 + $content = str_replace('[begin]', '', $content); // 首字格式支持 + $content = str_replace('[/begin]', '', $content); // 首字格式支持 + return $content; +} +add_filter('the_content', 'toc_support'); +add_filter('the_excerpt_rss', 'toc_support'); +add_filter('the_content_feed', 'toc_support'); + +// Markdown parser +/* 处理超时?? +function markdown_parser($content) { + include 'inc/Parsedown.php'; + $Parsedown = new Parsedown(); + $content = $Parsedown->text($content); + return $content; +} +add_filter( 'comment_text', 'markdown_parser' ); +*/ + +// 显示访客当前 IP +function get_the_user_ip() { +if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { +//check ip from share internet +$ip = $_SERVER['HTTP_CLIENT_IP']; +} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { +//to check ip is pass from proxy +$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; +} else { +$ip = $_SERVER['REMOTE_ADDR']; +} +return apply_filters( 'wpb_get_ip', $ip ); +} + +add_shortcode('show_ip', 'get_the_user_ip'); + + +/*歌词*/ +function hero_get_lyric() { + /** These are the lyrics to Hero */ + $lyrics = ""; + + // Here we split it into lines + $lyrics = explode( "\n", $lyrics ); + + // And then randomly choose a line + return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] ); +} + +// This just echoes the chosen line, we'll position it later +function hello_hero() { + $chosen = hero_get_lyric(); + echo $chosen; +} + +/*私密评论*/ +add_action('wp_ajax_nopriv_siren_private', 'siren_private'); +add_action('wp_ajax_siren_private', 'siren_private'); +function siren_private(){ + $comment_id = $_POST["p_id"]; + $action = $_POST["p_action"]; + if ($action == 'set_private') { + update_comment_meta($comment_id, '_private', 'true'); + $i_private = get_comment_meta($comment_ID, '_private', true); + if (!empty($i_private)) { + echo '否'; + } else { + echo '是'; + } + } + die; +} + +//时间序列 +function memory_archives_list() { + if( true ){ + $output = '

    [全部展开/收缩]

    '; + $the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1&post_type=post' ); //update: 加上忽略置顶文章 + $year=0; $mon=0; $i=0; $j=0; + while ( $the_query->have_posts() ) : $the_query->the_post(); + $year_tmp = get_the_time('Y'); + $mon_tmp = get_the_time('m'); + $y=$year; $m=$mon; + if ($mon != $mon_tmp && $mon > 0) $output .= '
  • '; + if ($year != $year_tmp && $year > 0) $output .= ''; + if ($year != $year_tmp) { + $year = $year_tmp; + $output .= '

    '. $year .' 年

    '; + #update_option('memory_archives_list', $output); + } + echo $output; +} + +/* + * 隐藏 Dashboard + */ +/* Remove the "Dashboard" from the admin menu for non-admin users */ +function remove_dashboard () { + global $current_user, $menu, $submenu; + get_currentuserinfo(); + + if( ! in_array( 'administrator', $current_user->roles ) ) { + reset( $menu ); + $page = key( $menu ); + while( ( __( 'Dashboard' ) != $menu[$page][0] ) && next( $menu ) ) { + $page = key( $menu ); + } + if( __( 'Dashboard' ) == $menu[$page][0] ) { + unset( $menu[$page] ); + } + reset($menu); + $page = key($menu); + while ( ! $current_user->has_cap( $menu[$page][1] ) && next( $menu ) ) { + $page = key( $menu ); + } + if ( preg_match( '#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI'] ) && + ( 'index.php' != $menu[$page][2] ) ) { + wp_redirect( get_option( 'siteurl' ) . '/wp-admin/profile.php'); + } + } +} +add_action('admin_menu', 'remove_dashboard'); + +/** + * Filter the except length to 20 words. 限制摘要长度(似乎无效) + * + * @param int $length Excerpt length. + * @return int (Maybe) modified excerpt length. + */ +function wpdocs_custom_excerpt_length( $length ) { + return 50; +} +add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 ); + + +/* + * 后台路径 + */ +/* +add_filter('site_url', 'wpadmin_filter', 10, 3); + function wpadmin_filter( $url, $path, $orig_scheme ) { + $old = array( "/(wp-admin)/"); + $admin_dir = WP_ADMIN_DIR; + $new = array($admin_dir); + return preg_replace( $old, $new, $url, 1); + } +*/ + +function admin_style() { + wp_enqueue_style('admin-styles-fix-icon', get_site_url() . '/wp-includes/css/dashicons.css'); + if ( get_user_option( 'admin_color' ) == "light" ) { + wp_enqueue_style('cus-styles-light', get_site_url() . '/wp-content/themes/Sakura/inc/css/dashboard-light.css'); + } +} +add_action('admin_enqueue_scripts', 'admin_style'); + +function custom_register_admin_scripts() { + wp_enqueue_script( 'lazyload', 'https://cdn.jsdelivr.net/npm/lazyload@2.0.0-beta.2/lazyload.min.js' ); +} +add_action( 'admin_enqueue_scripts', 'custom_register_admin_scripts' ); + + + +/* + * 后台通知 + */ +function notice_welcome() { + ?> +
    +

    +
    + ID, '_new_user', true); + if ($new_user) { + update_user_meta($user->ID, '_new_user', '0'); + + // do something for first login.. e.g., send a custom email + add_action( 'admin_notices', 'notice_welcome' ); + } +} +add_action('wp_login', 'shapeSpace_first_user_login', 10, 2); + +function recommend_light() { + $msg = 'Strongly recommend "Light" Scheme.'; + if ( get_user_locale( get_current_user_id() ) == "zh_CN") { + $msg = '管理界面配色方案建议使用“明亮”。'; + } + if ( get_user_locale( get_current_user_id() ) == "zh_TW") { + $msg = '管理色彩配置建議使用“明亮”。'; + } + if ( get_user_locale( get_current_user_id() ) == "ja") { + $msg = '管理画面の配色「ライト」を使用することをお勧めします。'; + } + if ( get_user_locale( get_current_user_id() ) == "ja-JP") { + $msg = '管理画面の配色「ライト」を使用することをお勧めします。'; + } + ?> +
    +

    +
    + add('invalid_email', __('ERROR: This email domain (@'.$email[1].') has been blocked. Please use another email.')); +} + +// lazyload images in atricles +function lazyload_img($content) { + if(!is_feed()) { + $content=preg_replace('//i',"\n",$content); + } + return $content; +} +add_filter('the_content', 'lazyload_img'); //替换文章关键词 +//add_filter( 'comment_text', 'lazyload_img' );//替换评论关键词 + +/* + * QQ 评论 + */ +// 数据库插入评论表单的qq字段 +add_action('wp_insert_comment','inlojv_sql_insert_qq_field',10,2); +function inlojv_sql_insert_qq_field($comment_ID,$commmentdata) { + $qq = isset($_POST['new_field_qq']) ? $_POST['new_field_qq'] : false; + update_comment_meta($comment_ID,'new_field_qq',$qq); // new_field_qq 是表单name值,也是存储在数据库里的字段名字 +} +// 后台评论中显示qq字段 +add_filter( 'manage_edit-comments_columns', 'add_comments_columns' ); +add_action( 'manage_comments_custom_column', 'output_comments_qq_columns', 10, 2 ); +function add_comments_columns( $columns ){ + $columns[ 'new_field_qq' ] = __( 'QQ' ); // 新增列名称 + return $columns; +} +function output_comments_qq_columns( $column_name, $comment_id ){ + switch( $column_name ) { + case "new_field_qq" : + // 这是输出值,可以拿来在前端输出,这里已经在钩子manage_comments_custom_column上输出了 + echo get_comment_meta( $comment_id, 'new_field_qq', true ); + break; + } +} +/** + * 头像调用路径 + */ +add_filter( 'get_avatar', 'inlojv_change_avatar', 10, 3 ); +function inlojv_change_avatar($avatar){ + global $comment; + if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true ) ){ + $qq_number = get_comment_meta( $comment->comment_ID, 'new_field_qq', true ); + return '😀'; + }else{ + return $avatar ; + } +} + +//code end diff --git a/header.php b/header.php new file mode 100644 index 0000000..7a511fb --- /dev/null +++ b/header.php @@ -0,0 +1,107 @@ + section and everything up until
    + * + * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials + * + * @package Akina + */ +?> + + +> + + + + +<?php global $page, $paged;wp_title( '-', true, 'right' ); +bloginfo( 'name' );$site_description = get_bloginfo( 'description', 'display' ); +if ( $site_description && ( is_home() || is_front_page() ) ) echo " - $site_description";if ( $paged >= 2 || $page >= 2 ) echo ' - ' . sprintf( __( '第 %s 页'), max( $paged, $page ) );?> + +name . ','; + }; + }; + if ($categories) { + foreach($categories as $category) { + $keywords .= $category->name . ','; + }; + }; + $description = mb_strimwidth( str_replace("\r\n", '', strip_tags($post->post_content)), 0, 240, '…'); + } else { + $keywords = akina_option('akina_meta_keywords'); + $description = akina_option('akina_meta_description'); + }; +?> + + + + + + + + + + + +> +
    +
    + +
    + +
    + +
    + + +
    \ No newline at end of file diff --git a/images/avatar.jpg b/images/avatar.jpg new file mode 100644 index 0000000..5f01c6e Binary files /dev/null and b/images/avatar.jpg differ diff --git a/images/favicon.ico b/images/favicon.ico new file mode 100644 index 0000000..46ff53c Binary files /dev/null and b/images/favicon.ico differ diff --git a/images/hd.png b/images/hd.png new file mode 100644 index 0000000..77748e7 Binary files /dev/null and b/images/hd.png differ diff --git a/images/login_loading.gif b/images/login_loading.gif new file mode 100644 index 0000000..b6bc6d0 Binary files /dev/null and b/images/login_loading.gif differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..cef8398 Binary files /dev/null and b/images/logo.png differ diff --git a/images/mashiro-logo-s.png b/images/mashiro-logo-s.png new file mode 100644 index 0000000..dcb775c Binary files /dev/null and b/images/mashiro-logo-s.png differ diff --git a/images/random/d-1.jpg b/images/random/d-1.jpg new file mode 100644 index 0000000..b6369ac Binary files /dev/null and b/images/random/d-1.jpg differ diff --git a/images/random/d-10.jpg b/images/random/d-10.jpg new file mode 100644 index 0000000..6fedab1 Binary files /dev/null and b/images/random/d-10.jpg differ diff --git a/images/random/d-2.jpg b/images/random/d-2.jpg new file mode 100644 index 0000000..d90b9fc Binary files /dev/null and b/images/random/d-2.jpg differ diff --git a/images/random/d-3.jpg b/images/random/d-3.jpg new file mode 100644 index 0000000..3b03505 Binary files /dev/null and b/images/random/d-3.jpg differ diff --git a/images/random/d-4.jpg b/images/random/d-4.jpg new file mode 100644 index 0000000..15c7f47 Binary files /dev/null and b/images/random/d-4.jpg differ diff --git a/images/random/d-5.jpg b/images/random/d-5.jpg new file mode 100644 index 0000000..3a5a08a Binary files /dev/null and b/images/random/d-5.jpg differ diff --git a/images/random/d-6.jpg b/images/random/d-6.jpg new file mode 100644 index 0000000..c25ef8f Binary files /dev/null and b/images/random/d-6.jpg differ diff --git a/images/random/d-7.jpg b/images/random/d-7.jpg new file mode 100644 index 0000000..565cf1c Binary files /dev/null and b/images/random/d-7.jpg differ diff --git a/images/random/d-8.jpg b/images/random/d-8.jpg new file mode 100644 index 0000000..da7a391 Binary files /dev/null and b/images/random/d-8.jpg differ diff --git a/images/random/d-9.jpg b/images/random/d-9.jpg new file mode 100644 index 0000000..85e7782 Binary files /dev/null and b/images/random/d-9.jpg differ diff --git a/images/smilies/bili/baiyan.png b/images/smilies/bili/baiyan.png new file mode 100644 index 0000000..f20ff32 Binary files /dev/null and b/images/smilies/bili/baiyan.png differ diff --git a/images/smilies/bili/bishi.png b/images/smilies/bili/bishi.png new file mode 100644 index 0000000..fc78499 Binary files /dev/null and b/images/smilies/bili/bishi.png differ diff --git a/images/smilies/bili/bizui.png b/images/smilies/bili/bizui.png new file mode 100644 index 0000000..3943c48 Binary files /dev/null and b/images/smilies/bili/bizui.png differ diff --git a/images/smilies/bili/chan.png b/images/smilies/bili/chan.png new file mode 100644 index 0000000..d567051 Binary files /dev/null and b/images/smilies/bili/chan.png differ diff --git a/images/smilies/bili/daku.png b/images/smilies/bili/daku.png new file mode 100644 index 0000000..dd3b946 Binary files /dev/null and b/images/smilies/bili/daku.png differ diff --git a/images/smilies/bili/dalao.png b/images/smilies/bili/dalao.png new file mode 100644 index 0000000..4cc58a7 Binary files /dev/null and b/images/smilies/bili/dalao.png differ diff --git a/images/smilies/bili/dalian.png b/images/smilies/bili/dalian.png new file mode 100644 index 0000000..8e51b61 Binary files /dev/null and b/images/smilies/bili/dalian.png differ diff --git a/images/smilies/bili/dianzan.png b/images/smilies/bili/dianzan.png new file mode 100644 index 0000000..8b9c924 Binary files /dev/null and b/images/smilies/bili/dianzan.png differ diff --git a/images/smilies/bili/doge.png b/images/smilies/bili/doge.png new file mode 100644 index 0000000..4b7e196 Binary files /dev/null and b/images/smilies/bili/doge.png differ diff --git a/images/smilies/bili/facai.png b/images/smilies/bili/facai.png new file mode 100644 index 0000000..dc78278 Binary files /dev/null and b/images/smilies/bili/facai.png differ diff --git a/images/smilies/bili/fadai.png b/images/smilies/bili/fadai.png new file mode 100644 index 0000000..d2d3351 Binary files /dev/null and b/images/smilies/bili/fadai.png differ diff --git a/images/smilies/bili/fanu.png b/images/smilies/bili/fanu.png new file mode 100644 index 0000000..a413df2 Binary files /dev/null and b/images/smilies/bili/fanu.png differ diff --git a/images/smilies/bili/ganga.png b/images/smilies/bili/ganga.png new file mode 100644 index 0000000..fa1050a Binary files /dev/null and b/images/smilies/bili/ganga.png differ diff --git a/images/smilies/bili/guilian.png b/images/smilies/bili/guilian.png new file mode 100644 index 0000000..be65b10 Binary files /dev/null and b/images/smilies/bili/guilian.png differ diff --git a/images/smilies/bili/guzhang.png b/images/smilies/bili/guzhang.png new file mode 100644 index 0000000..c2a7670 Binary files /dev/null and b/images/smilies/bili/guzhang.png differ diff --git a/images/smilies/bili/haixiu.png b/images/smilies/bili/haixiu.png new file mode 100644 index 0000000..99c9761 Binary files /dev/null and b/images/smilies/bili/haixiu.png differ diff --git a/images/smilies/bili/heirenwenhao.png b/images/smilies/bili/heirenwenhao.png new file mode 100644 index 0000000..02eef81 Binary files /dev/null and b/images/smilies/bili/heirenwenhao.png differ diff --git a/images/smilies/bili/huaixiao.png b/images/smilies/bili/huaixiao.png new file mode 100644 index 0000000..4004aff Binary files /dev/null and b/images/smilies/bili/huaixiao.png differ diff --git a/images/smilies/bili/jingxia.png b/images/smilies/bili/jingxia.png new file mode 100644 index 0000000..698d797 Binary files /dev/null and b/images/smilies/bili/jingxia.png differ diff --git a/images/smilies/bili/keai.png b/images/smilies/bili/keai.png new file mode 100644 index 0000000..dcc917d Binary files /dev/null and b/images/smilies/bili/keai.png differ diff --git a/images/smilies/bili/koubi.png b/images/smilies/bili/koubi.png new file mode 100644 index 0000000..91eaf24 Binary files /dev/null and b/images/smilies/bili/koubi.png differ diff --git a/images/smilies/bili/kun.png b/images/smilies/bili/kun.png new file mode 100644 index 0000000..8effe55 Binary files /dev/null and b/images/smilies/bili/kun.png differ diff --git a/images/smilies/bili/lengmo.png b/images/smilies/bili/lengmo.png new file mode 100644 index 0000000..5f40f7c Binary files /dev/null and b/images/smilies/bili/lengmo.png differ diff --git a/images/smilies/bili/liubixue.png b/images/smilies/bili/liubixue.png new file mode 100644 index 0000000..fb6b99e Binary files /dev/null and b/images/smilies/bili/liubixue.png differ diff --git a/images/smilies/bili/liuhan.png b/images/smilies/bili/liuhan.png new file mode 100644 index 0000000..2c95ecf Binary files /dev/null and b/images/smilies/bili/liuhan.png differ diff --git a/images/smilies/bili/liulei.png b/images/smilies/bili/liulei.png new file mode 100644 index 0000000..71577cf Binary files /dev/null and b/images/smilies/bili/liulei.png differ diff --git a/images/smilies/bili/miantian.png b/images/smilies/bili/miantian.png new file mode 100644 index 0000000..d6236b7 Binary files /dev/null and b/images/smilies/bili/miantian.png differ diff --git a/images/smilies/bili/mudengkoudai.png b/images/smilies/bili/mudengkoudai.png new file mode 100644 index 0000000..19114d4 Binary files /dev/null and b/images/smilies/bili/mudengkoudai.png differ diff --git a/images/smilies/bili/nanguo.png b/images/smilies/bili/nanguo.png new file mode 100644 index 0000000..16f2434 Binary files /dev/null and b/images/smilies/bili/nanguo.png differ diff --git a/images/smilies/bili/outu.png b/images/smilies/bili/outu.png new file mode 100644 index 0000000..8718015 Binary files /dev/null and b/images/smilies/bili/outu.png differ diff --git a/images/smilies/bili/qinqin.png b/images/smilies/bili/qinqin.png new file mode 100644 index 0000000..8132cdf Binary files /dev/null and b/images/smilies/bili/qinqin.png differ diff --git a/images/smilies/bili/se.png b/images/smilies/bili/se.png new file mode 100644 index 0000000..2039ac7 Binary files /dev/null and b/images/smilies/bili/se.png differ diff --git a/images/smilies/bili/shengbing.png b/images/smilies/bili/shengbing.png new file mode 100644 index 0000000..42c3637 Binary files /dev/null and b/images/smilies/bili/shengbing.png differ diff --git a/images/smilies/bili/shengqi.png b/images/smilies/bili/shengqi.png new file mode 100644 index 0000000..9e431cf Binary files /dev/null and b/images/smilies/bili/shengqi.png differ diff --git a/images/smilies/bili/shuizhao.png b/images/smilies/bili/shuizhao.png new file mode 100644 index 0000000..7433eb8 Binary files /dev/null and b/images/smilies/bili/shuizhao.png differ diff --git a/images/smilies/bili/sikao.png b/images/smilies/bili/sikao.png new file mode 100644 index 0000000..95cd2ee Binary files /dev/null and b/images/smilies/bili/sikao.png differ diff --git a/images/smilies/bili/tiaokan.png b/images/smilies/bili/tiaokan.png new file mode 100644 index 0000000..e992567 Binary files /dev/null and b/images/smilies/bili/tiaokan.png differ diff --git a/images/smilies/bili/tiaopi.png b/images/smilies/bili/tiaopi.png new file mode 100644 index 0000000..2b5b028 Binary files /dev/null and b/images/smilies/bili/tiaopi.png differ diff --git a/images/smilies/bili/touxiao.png b/images/smilies/bili/touxiao.png new file mode 100644 index 0000000..f04df88 Binary files /dev/null and b/images/smilies/bili/touxiao.png differ diff --git a/images/smilies/bili/tuxue.png b/images/smilies/bili/tuxue.png new file mode 100644 index 0000000..4f406c7 Binary files /dev/null and b/images/smilies/bili/tuxue.png differ diff --git a/images/smilies/bili/weiqu.png b/images/smilies/bili/weiqu.png new file mode 100644 index 0000000..1fe6002 Binary files /dev/null and b/images/smilies/bili/weiqu.png differ diff --git a/images/smilies/bili/weixiao.png b/images/smilies/bili/weixiao.png new file mode 100644 index 0000000..8ab9511 Binary files /dev/null and b/images/smilies/bili/weixiao.png differ diff --git a/images/smilies/bili/wunai.png b/images/smilies/bili/wunai.png new file mode 100644 index 0000000..1d04631 Binary files /dev/null and b/images/smilies/bili/wunai.png differ diff --git a/images/smilies/bili/xiaoku.png b/images/smilies/bili/xiaoku.png new file mode 100644 index 0000000..1734fd3 Binary files /dev/null and b/images/smilies/bili/xiaoku.png differ diff --git a/images/smilies/bili/xieyanxiao.png b/images/smilies/bili/xieyanxiao.png new file mode 100644 index 0000000..50d1a8f Binary files /dev/null and b/images/smilies/bili/xieyanxiao.png differ diff --git a/images/smilies/bili/yiwen.png b/images/smilies/bili/yiwen.png new file mode 100644 index 0000000..4e1246a Binary files /dev/null and b/images/smilies/bili/yiwen.png differ diff --git a/images/smilies/bili/yun.png b/images/smilies/bili/yun.png new file mode 100644 index 0000000..8385b34 Binary files /dev/null and b/images/smilies/bili/yun.png differ diff --git a/images/smilies/bili/zaijian.png b/images/smilies/bili/zaijian.png new file mode 100644 index 0000000..9d5b068 Binary files /dev/null and b/images/smilies/bili/zaijian.png differ diff --git a/images/smilies/bili/zhoumei.png b/images/smilies/bili/zhoumei.png new file mode 100644 index 0000000..4ae9202 Binary files /dev/null and b/images/smilies/bili/zhoumei.png differ diff --git a/images/smilies/bili/zhuakuang.png b/images/smilies/bili/zhuakuang.png new file mode 100644 index 0000000..8c78712 Binary files /dev/null and b/images/smilies/bili/zhuakuang.png differ diff --git a/images/smilies/icon_Grievance.gif b/images/smilies/icon_Grievance.gif new file mode 100644 index 0000000..2945d5b Binary files /dev/null and b/images/smilies/icon_Grievance.gif differ diff --git a/images/smilies/icon_Happy.gif b/images/smilies/icon_Happy.gif new file mode 100644 index 0000000..86dc343 Binary files /dev/null and b/images/smilies/icon_Happy.gif differ diff --git a/images/smilies/icon_aa.gif b/images/smilies/icon_aa.gif new file mode 100644 index 0000000..8ceac61 Binary files /dev/null and b/images/smilies/icon_aa.gif differ diff --git a/images/smilies/icon_anger.gif b/images/smilies/icon_anger.gif new file mode 100644 index 0000000..2180cd8 Binary files /dev/null and b/images/smilies/icon_anger.gif differ diff --git a/images/smilies/icon_awesome.gif b/images/smilies/icon_awesome.gif new file mode 100644 index 0000000..23c7e3a Binary files /dev/null and b/images/smilies/icon_awesome.gif differ diff --git a/images/smilies/icon_bbd.gif b/images/smilies/icon_bbd.gif new file mode 100644 index 0000000..e54df9b Binary files /dev/null and b/images/smilies/icon_bbd.gif differ diff --git a/images/smilies/icon_britan.gif b/images/smilies/icon_britan.gif new file mode 100644 index 0000000..e4dedaa Binary files /dev/null and b/images/smilies/icon_britan.gif differ diff --git a/images/smilies/icon_doubt.gif b/images/smilies/icon_doubt.gif new file mode 100644 index 0000000..4afe367 Binary files /dev/null and b/images/smilies/icon_doubt.gif differ diff --git a/images/smilies/icon_good.gif b/images/smilies/icon_good.gif new file mode 100644 index 0000000..b823b62 Binary files /dev/null and b/images/smilies/icon_good.gif differ diff --git a/images/smilies/icon_haha.gif b/images/smilies/icon_haha.gif new file mode 100644 index 0000000..2f33084 Binary files /dev/null and b/images/smilies/icon_haha.gif differ diff --git a/images/smilies/icon_han.gif b/images/smilies/icon_han.gif new file mode 100644 index 0000000..b836d61 Binary files /dev/null and b/images/smilies/icon_han.gif differ diff --git a/images/smilies/icon_hu.gif b/images/smilies/icon_hu.gif new file mode 100644 index 0000000..e631ad7 Binary files /dev/null and b/images/smilies/icon_hu.gif differ diff --git a/images/smilies/icon_huaji.gif b/images/smilies/icon_huaji.gif new file mode 100644 index 0000000..f4b649f Binary files /dev/null and b/images/smilies/icon_huaji.gif differ diff --git a/images/smilies/icon_ku.gif b/images/smilies/icon_ku.gif new file mode 100644 index 0000000..15f9f2d Binary files /dev/null and b/images/smilies/icon_ku.gif differ diff --git a/images/smilies/icon_naive.gif b/images/smilies/icon_naive.gif new file mode 100644 index 0000000..2f3f629 Binary files /dev/null and b/images/smilies/icon_naive.gif differ diff --git a/images/smilies/icon_niconiconi.gif b/images/smilies/icon_niconiconi.gif new file mode 100644 index 0000000..3f1cec1 Binary files /dev/null and b/images/smilies/icon_niconiconi.gif differ diff --git a/images/smilies/icon_niconiconi_t.gif b/images/smilies/icon_niconiconi_t.gif new file mode 100644 index 0000000..8ac8224 Binary files /dev/null and b/images/smilies/icon_niconiconi_t.gif differ diff --git a/images/smilies/icon_niconiconit.gif b/images/smilies/icon_niconiconit.gif new file mode 100644 index 0000000..8ac8224 Binary files /dev/null and b/images/smilies/icon_niconiconit.gif differ diff --git a/images/smilies/icon_rbq.gif b/images/smilies/icon_rbq.gif new file mode 100644 index 0000000..50a3e63 Binary files /dev/null and b/images/smilies/icon_rbq.gif differ diff --git a/images/smilies/icon_reluctantly.gif b/images/smilies/icon_reluctantly.gif new file mode 100644 index 0000000..1686dbe Binary files /dev/null and b/images/smilies/icon_reluctantly.gif differ diff --git a/images/smilies/icon_rmb.gif b/images/smilies/icon_rmb.gif new file mode 100644 index 0000000..4234236 Binary files /dev/null and b/images/smilies/icon_rmb.gif differ diff --git a/images/smilies/icon_se.gif b/images/smilies/icon_se.gif new file mode 100644 index 0000000..ec3fcaf Binary files /dev/null and b/images/smilies/icon_se.gif differ diff --git a/images/smilies/icon_shame.gif b/images/smilies/icon_shame.gif new file mode 100644 index 0000000..ba42021 Binary files /dev/null and b/images/smilies/icon_shame.gif differ diff --git a/images/smilies/icon_shui.gif b/images/smilies/icon_shui.gif new file mode 100644 index 0000000..89a8b52 Binary files /dev/null and b/images/smilies/icon_shui.gif differ diff --git a/images/smilies/icon_smilingeyes.gif b/images/smilies/icon_smilingeyes.gif new file mode 100644 index 0000000..8c11611 Binary files /dev/null and b/images/smilies/icon_smilingeyes.gif differ diff --git a/images/smilies/icon_spit.gif b/images/smilies/icon_spit.gif new file mode 100644 index 0000000..5f4ada8 Binary files /dev/null and b/images/smilies/icon_spit.gif differ diff --git a/images/smilies/icon_spray.gif b/images/smilies/icon_spray.gif new file mode 100644 index 0000000..00d601c Binary files /dev/null and b/images/smilies/icon_spray.gif differ diff --git a/images/smilies/icon_surprised.gif b/images/smilies/icon_surprised.gif new file mode 100644 index 0000000..2d7f1c3 Binary files /dev/null and b/images/smilies/icon_surprised.gif differ diff --git a/images/smilies/icon_surprised2.gif b/images/smilies/icon_surprised2.gif new file mode 100644 index 0000000..9ef77f4 Binary files /dev/null and b/images/smilies/icon_surprised2.gif differ diff --git a/images/smilies/icon_tear.gif b/images/smilies/icon_tear.gif new file mode 100644 index 0000000..b96dcd2 Binary files /dev/null and b/images/smilies/icon_tear.gif differ diff --git a/images/smilies/icon_theblackline.gif b/images/smilies/icon_theblackline.gif new file mode 100644 index 0000000..afc6b86 Binary files /dev/null and b/images/smilies/icon_theblackline.gif differ diff --git a/images/smilies/icon_tongue.gif b/images/smilies/icon_tongue.gif new file mode 100644 index 0000000..157c2a1 Binary files /dev/null and b/images/smilies/icon_tongue.gif differ diff --git a/images/temp.jpg b/images/temp.jpg new file mode 100644 index 0000000..bbd12f2 Binary files /dev/null and b/images/temp.jpg differ diff --git a/images/temp.png b/images/temp.png new file mode 100644 index 0000000..74d0520 Binary files /dev/null and b/images/temp.png differ diff --git a/inc/Parsedown.php b/inc/Parsedown.php new file mode 100644 index 0000000..87d612a --- /dev/null +++ b/inc/Parsedown.php @@ -0,0 +1,1679 @@ +DefinitionData = array(); + + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + # remove surrounding line breaks + $text = trim($text, "\n"); + + # split text into lines + $lines = explode("\n", $text); + + # iterate through lines to identify blocks + $markup = $this->lines($lines); + + # trim line breaks + $markup = trim($markup, "\n"); + + return $markup; + } + + # + # Setters + # + + function setBreaksEnabled($breaksEnabled) + { + $this->breaksEnabled = $breaksEnabled; + + return $this; + } + + protected $breaksEnabled; + + function setMarkupEscaped($markupEscaped) + { + $this->markupEscaped = $markupEscaped; + + return $this; + } + + protected $markupEscaped; + + function setUrlsLinked($urlsLinked) + { + $this->urlsLinked = $urlsLinked; + + return $this; + } + + protected $urlsLinked = true; + + function setSafeMode($safeMode) + { + $this->safeMode = (bool) $safeMode; + + return $this; + } + + protected $safeMode; + + protected $safeLinksWhitelist = array( + 'http://', + 'https://', + 'ftp://', + 'ftps://', + 'mailto:', + 'data:image/png;base64,', + 'data:image/gif;base64,', + 'data:image/jpeg;base64,', + 'irc:', + 'ircs:', + 'git:', + 'ssh:', + 'news:', + 'steam:', + ); + + # + # Lines + # + + protected $BlockTypes = array( + '#' => array('Header'), + '*' => array('Rule', 'List'), + '+' => array('List'), + '-' => array('SetextHeader', 'Table', 'Rule', 'List'), + '0' => array('List'), + '1' => array('List'), + '2' => array('List'), + '3' => array('List'), + '4' => array('List'), + '5' => array('List'), + '6' => array('List'), + '7' => array('List'), + '8' => array('List'), + '9' => array('List'), + ':' => array('Table'), + '<' => array('Comment', 'Markup'), + '=' => array('SetextHeader'), + '>' => array('Quote'), + '[' => array('Reference'), + '_' => array('Rule'), + '`' => array('FencedCode'), + '|' => array('Table'), + '~' => array('FencedCode'), + ); + + # ~ + + protected $unmarkedBlockTypes = array( + 'Code', + ); + + # + # Blocks + # + + protected function lines(array $lines) + { + $CurrentBlock = null; + + foreach ($lines as $line) + { + if (chop($line) === '') + { + if (isset($CurrentBlock)) + { + $CurrentBlock['interrupted'] = true; + } + + continue; + } + + if (strpos($line, "\t") !== false) + { + $parts = explode("\t", $line); + + $line = $parts[0]; + + unset($parts[0]); + + foreach ($parts as $part) + { + $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + + $line .= str_repeat(' ', $shortage); + $line .= $part; + } + } + + $indent = 0; + + while (isset($line[$indent]) and $line[$indent] === ' ') + { + $indent ++; + } + + $text = $indent > 0 ? substr($line, $indent) : $line; + + # ~ + + $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); + + # ~ + + if (isset($CurrentBlock['continuable'])) + { + $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock); + + if (isset($Block)) + { + $CurrentBlock = $Block; + + continue; + } + else + { + if ($this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + } + } + + # ~ + + $marker = $text[0]; + + # ~ + + $blockTypes = $this->unmarkedBlockTypes; + + if (isset($this->BlockTypes[$marker])) + { + foreach ($this->BlockTypes[$marker] as $blockType) + { + $blockTypes []= $blockType; + } + } + + # + # ~ + + foreach ($blockTypes as $blockType) + { + $Block = $this->{'block'.$blockType}($Line, $CurrentBlock); + + if (isset($Block)) + { + $Block['type'] = $blockType; + + if ( ! isset($Block['identified'])) + { + $Blocks []= $CurrentBlock; + + $Block['identified'] = true; + } + + if ($this->isBlockContinuable($blockType)) + { + $Block['continuable'] = true; + } + + $CurrentBlock = $Block; + + continue 2; + } + } + + # ~ + + if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) + { + $CurrentBlock['element']['text'] .= "\n".$text; + } + else + { + $Blocks []= $CurrentBlock; + + $CurrentBlock = $this->paragraph($Line); + + $CurrentBlock['identified'] = true; + } + } + + # ~ + + if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + + # ~ + + $Blocks []= $CurrentBlock; + + unset($Blocks[0]); + + # ~ + + $markup = ''; + + foreach ($Blocks as $Block) + { + if (isset($Block['hidden'])) + { + continue; + } + + $markup .= "\n"; + $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']); + } + + $markup .= "\n"; + + # ~ + + return $markup; + } + + protected function isBlockContinuable($Type) + { + return method_exists($this, 'block'.$Type.'Continue'); + } + + protected function isBlockCompletable($Type) + { + return method_exists($this, 'block'.$Type.'Complete'); + } + + # + # Code + + protected function blockCode($Line, $Block = null) + { + if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] >= 4) + { + $text = substr($Line['body'], 4); + + $Block = array( + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => array( + 'name' => 'code', + 'text' => $text, + ), + ), + ); + + return $Block; + } + } + + protected function blockCodeContinue($Line, $Block) + { + if ($Line['indent'] >= 4) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['element']['text']['text'] .= "\n"; + + $text = substr($Line['body'], 4); + + $Block['element']['text']['text'] .= $text; + + return $Block; + } + } + + protected function blockCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Comment + + protected function blockComment($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + { + $Block = array( + 'markup' => $Line['body'], + ); + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function blockCommentContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['markup'] .= "\n" . $Line['body']; + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + + # + # Fenced Code + + protected function blockFencedCode($Line) + { + if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches)) + { + $Element = array( + 'name' => 'code', + 'text' => '', + ); + + if (isset($matches[1])) + { + $class = 'language-'.$matches[1]; + + $Element['attributes'] = array( + 'class' => $class, + ); + } + + $Block = array( + 'char' => $Line['text'][0], + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => $Element, + ), + ); + + return $Block; + } + } + + protected function blockFencedCodeContinue($Line, $Block) + { + if (isset($Block['complete'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text'])) + { + $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1); + + $Block['complete'] = true; + + return $Block; + } + + $Block['element']['text']['text'] .= "\n".$Line['body']; + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Header + + protected function blockHeader($Line) + { + if (isset($Line['text'][1])) + { + $level = 1; + + while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') + { + $level ++; + } + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '# '); + + $Block = array( + 'element' => array( + 'name' => 'h' . min(6, $level), + 'text' => $text, + 'handler' => 'line', + ), + ); + + return $Block; + } + } + + # + # List + + protected function blockList($Line) + { + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); + + if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'indent' => $Line['indent'], + 'pattern' => $pattern, + 'element' => array( + 'name' => $name, + 'handler' => 'elements', + ), + ); + + if($name === 'ol') + { + $listStart = stristr($matches[0], '.', true); + + if($listStart !== '1') + { + $Block['element']['attributes'] = array('start' => $listStart); + } + } + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $matches[2], + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + } + + protected function blockListContinue($Line, array $Block) + { + if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['li']['text'] []= ''; + + $Block['loose'] = true; + + unset($Block['interrupted']); + } + + unset($Block['li']); + + $text = isset($matches[1]) ? $matches[1] : ''; + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $text, + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + + if ($Line['text'][0] === '[' and $this->blockReference($Line)) + { + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + return $Block; + } + + if ($Line['indent'] > 0) + { + $Block['li']['text'] []= ''; + + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + unset($Block['interrupted']); + + return $Block; + } + } + + protected function blockListComplete(array $Block) + { + if (isset($Block['loose'])) + { + foreach ($Block['element']['text'] as &$li) + { + if (end($li['text']) !== '') + { + $li['text'] []= ''; + } + } + } + + return $Block; + } + + # + # Quote + + protected function blockQuote($Line) + { + if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'element' => array( + 'name' => 'blockquote', + 'handler' => 'lines', + 'text' => (array) $matches[1], + ), + ); + + return $Block; + } + } + + protected function blockQuoteContinue($Line, array $Block) + { + if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text'] []= ''; + + unset($Block['interrupted']); + } + + $Block['element']['text'] []= $matches[1]; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $Block['element']['text'] []= $Line['text']; + + return $Block; + } + } + + # + # Rule + + protected function blockRule($Line) + { + if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) + { + $Block = array( + 'element' => array( + 'name' => 'hr' + ), + ); + + return $Block; + } + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (chop($Line['text'], $Line['text'][0]) === '') + { + $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; + + return $Block; + } + } + + # + # Markup + + protected function blockMarkup($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) + { + $element = strtolower($matches[1]); + + if (in_array($element, $this->textLevelElements)) + { + return; + } + + $Block = array( + 'name' => $matches[1], + 'depth' => 0, + 'markup' => $Line['text'], + ); + + $length = strlen($matches[0]); + + $remainder = substr($Line['text'], $length); + + if (trim($remainder) === '') + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + $Block['closed'] = true; + + $Block['void'] = true; + } + } + else + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + return; + } + + if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder)) + { + $Block['closed'] = true; + } + } + + return $Block; + } + } + + protected function blockMarkupContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open + { + $Block['depth'] ++; + } + + if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close + { + if ($Block['depth'] > 0) + { + $Block['depth'] --; + } + else + { + $Block['closed'] = true; + } + } + + if (isset($Block['interrupted'])) + { + $Block['markup'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['markup'] .= "\n".$Line['body']; + + return $Block; + } + + # + # Reference + + protected function blockReference($Line) + { + if (preg_match('/^\[(.+?)\]:[ ]*?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) + { + $id = strtolower($matches[1]); + + $Data = array( + 'url' => $matches[2], + 'title' => null, + ); + + if (isset($matches[3])) + { + $Data['title'] = $matches[3]; + } + + $this->DefinitionData['Reference'][$id] = $Data; + + $Block = array( + 'hidden' => true, + ); + + return $Block; + } + } + + # + # Table + + protected function blockTable($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '') + { + $alignments = array(); + + $divider = $Line['text']; + + $divider = trim($divider); + $divider = trim($divider, '|'); + + $dividerCells = explode('|', $divider); + + foreach ($dividerCells as $dividerCell) + { + $dividerCell = trim($dividerCell); + + if ($dividerCell === '') + { + continue; + } + + $alignment = null; + + if ($dividerCell[0] === ':') + { + $alignment = 'left'; + } + + if (substr($dividerCell, - 1) === ':') + { + $alignment = $alignment === 'left' ? 'center' : 'right'; + } + + $alignments []= $alignment; + } + + # ~ + + $HeaderElements = array(); + + $header = $Block['element']['text']; + + $header = trim($header); + $header = trim($header, '|'); + + $headerCells = explode('|', $header); + + foreach ($headerCells as $index => $headerCell) + { + $headerCell = trim($headerCell); + + $HeaderElement = array( + 'name' => 'th', + 'text' => $headerCell, + 'handler' => 'line', + ); + + if (isset($alignments[$index])) + { + $alignment = $alignments[$index]; + + $HeaderElement['attributes'] = array( + 'style' => 'text-align: '.$alignment.';', + ); + } + + $HeaderElements []= $HeaderElement; + } + + # ~ + + $Block = array( + 'alignments' => $alignments, + 'identified' => true, + 'element' => array( + 'name' => 'table', + 'handler' => 'elements', + ), + ); + + $Block['element']['text'] []= array( + 'name' => 'thead', + 'handler' => 'elements', + ); + + $Block['element']['text'] []= array( + 'name' => 'tbody', + 'handler' => 'elements', + 'text' => array(), + ); + + $Block['element']['text'][0]['text'] []= array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $HeaderElements, + ); + + return $Block; + } + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); + + foreach ($matches[0] as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => 'line', + 'text' => $cell, + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: '.$Block['alignments'][$index].';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $Elements, + ); + + $Block['element']['text'][1]['text'] []= $Element; + + return $Block; + } + } + + # + # ~ + # + + protected function paragraph($Line) + { + $Block = array( + 'element' => array( + 'name' => 'p', + 'text' => $Line['text'], + 'handler' => 'line', + ), + ); + + return $Block; + } + + # + # Inline Elements + # + + protected $InlineTypes = array( + '"' => array('SpecialCharacter'), + '!' => array('Image'), + '&' => array('SpecialCharacter'), + '*' => array('Emphasis'), + ':' => array('Url'), + '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'), + '>' => array('SpecialCharacter'), + '[' => array('Link'), + '_' => array('Emphasis'), + '`' => array('Code'), + '~' => array('Strikethrough'), + '\\' => array('EscapeSequence'), + ); + + # ~ + + protected $inlineMarkerList = '!"*_&[:<>`~\\'; + + # + # ~ + # + + public function line($text, $nonNestables=array()) + { + $markup = ''; + + # $excerpt is based on the first occurrence of a marker + + while ($excerpt = strpbrk($text, $this->inlineMarkerList)) + { + $marker = $excerpt[0]; + + $markerPosition = strpos($text, $marker); + + $Excerpt = array('text' => $excerpt, 'context' => $text); + + foreach ($this->InlineTypes[$marker] as $inlineType) + { + # check to see if the current inline type is nestable in the current context + + if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables)) + { + continue; + } + + $Inline = $this->{'inline'.$inlineType}($Excerpt); + + if ( ! isset($Inline)) + { + continue; + } + + # makes sure that the inline belongs to "our" marker + + if (isset($Inline['position']) and $Inline['position'] > $markerPosition) + { + continue; + } + + # sets a default inline position + + if ( ! isset($Inline['position'])) + { + $Inline['position'] = $markerPosition; + } + + # cause the new element to 'inherit' our non nestables + + foreach ($nonNestables as $non_nestable) + { + $Inline['element']['nonNestables'][] = $non_nestable; + } + + # the text that comes before the inline + $unmarkedText = substr($text, 0, $Inline['position']); + + # compile the unmarked text + $markup .= $this->unmarkedText($unmarkedText); + + # compile the inline + $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); + + # remove the examined text + $text = substr($text, $Inline['position'] + $Inline['extent']); + + continue 2; + } + + # the marker does not belong to an inline + + $unmarkedText = substr($text, 0, $markerPosition + 1); + + $markup .= $this->unmarkedText($unmarkedText); + + $text = substr($text, $markerPosition + 1); + } + + $markup .= $this->unmarkedText($text); + + return $markup; + } + + # + # ~ + # + + protected function inlineCode($Excerpt) + { + $marker = $Excerpt['text'][0]; + + if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]), + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ); + } + } + + protected function inlineEmailTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + if ( ! isset($matches[2])) + { + $url = 'mailto:' . $url; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $matches[1], + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + protected function inlineEmphasis($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + $marker = $Excerpt['text'][0]; + + if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'strong'; + } + elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'em'; + } + else + { + return; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => $emphasis, + 'handler' => 'line', + 'text' => $matches[1], + ), + ); + } + + protected function inlineEscapeSequence($Excerpt) + { + if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) + { + return array( + 'markup' => $Excerpt['text'][1], + 'extent' => 2, + ); + } + } + + protected function inlineImage($Excerpt) + { + if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') + { + return; + } + + $Excerpt['text']= substr($Excerpt['text'], 1); + + $Link = $this->inlineLink($Excerpt); + + if ($Link === null) + { + return; + } + + $Inline = array( + 'extent' => $Link['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $Link['element']['attributes']['href'], + 'alt' => $Link['element']['text'], + ), + ), + ); + + $Inline['element']['attributes'] += $Link['element']['attributes']; + + unset($Inline['element']['attributes']['href']); + + return $Inline; + } + + protected function inlineLink($Excerpt) + { + $Element = array( + 'name' => 'a', + 'handler' => 'line', + 'nonNestables' => array('Url', 'Link'), + 'text' => null, + 'attributes' => array( + 'href' => null, + 'title' => null, + ), + ); + + $extent = 0; + + $remainder = $Excerpt['text']; + + if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches)) + { + $Element['text'] = $matches[1]; + + $extent += strlen($matches[0]); + + $remainder = substr($remainder, $extent); + } + else + { + return; + } + + if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*"|\'[^\']*\'))?\s*[)]/', $remainder, $matches)) + { + $Element['attributes']['href'] = $matches[1]; + + if (isset($matches[2])) + { + $Element['attributes']['title'] = substr($matches[2], 1, - 1); + } + + $extent += strlen($matches[0]); + } + else + { + if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) + { + $definition = strlen($matches[1]) ? $matches[1] : $Element['text']; + $definition = strtolower($definition); + + $extent += strlen($matches[0]); + } + else + { + $definition = strtolower($Element['text']); + } + + if ( ! isset($this->DefinitionData['Reference'][$definition])) + { + return; + } + + $Definition = $this->DefinitionData['Reference'][$definition]; + + $Element['attributes']['href'] = $Definition['url']; + $Element['attributes']['title'] = $Definition['title']; + } + + return array( + 'extent' => $extent, + 'element' => $Element, + ); + } + + protected function inlineMarkup($Excerpt) + { + if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) + { + return; + } + + if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + } + + protected function inlineSpecialCharacter($Excerpt) + { + if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) + { + return array( + 'markup' => '&', + 'extent' => 1, + ); + } + + $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); + + if (isset($SpecialCharacter[$Excerpt['text'][0]])) + { + return array( + 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';', + 'extent' => 1, + ); + } + } + + protected function inlineStrikethrough($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) + { + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'del', + 'text' => $matches[1], + 'handler' => 'line', + ), + ); + } + } + + protected function inlineUrl($Excerpt) + { + if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') + { + return; + } + + if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) + { + $url = $matches[0][0]; + + $Inline = array( + 'extent' => strlen($matches[0][0]), + 'position' => $matches[0][1], + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + + return $Inline; + } + } + + protected function inlineUrlTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + # ~ + + protected function unmarkedText($text) + { + if ($this->breaksEnabled) + { + $text = preg_replace('/[ ]*\n/', "
    \n", $text); + } + else + { + $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "
    \n", $text); + $text = str_replace(" \n", "\n", $text); + } + + return $text; + } + + # + # Handlers + # + + protected function element(array $Element) + { + if ($this->safeMode) + { + $Element = $this->sanitiseElement($Element); + } + + $markup = '<'.$Element['name']; + + if (isset($Element['attributes'])) + { + foreach ($Element['attributes'] as $name => $value) + { + if ($value === null) + { + continue; + } + + $markup .= ' '.$name.'="'.self::escape($value).'"'; + } + } + + if (isset($Element['text'])) + { + $markup .= '>'; + + if (!isset($Element['nonNestables'])) + { + $Element['nonNestables'] = array(); + } + + if (isset($Element['handler'])) + { + $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']); + } + else + { + $markup .= self::escape($Element['text'], true); + } + + $markup .= ''; + } + else + { + $markup .= ' />'; + } + + return $markup; + } + + protected function elements(array $Elements) + { + $markup = ''; + + foreach ($Elements as $Element) + { + $markup .= "\n" . $this->element($Element); + } + + $markup .= "\n"; + + return $markup; + } + + # ~ + + protected function li($lines) + { + $markup = $this->lines($lines); + + $trimmedMarkup = trim($markup); + + if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

    ') + { + $markup = $trimmedMarkup; + $markup = substr($markup, 3); + + $position = strpos($markup, "

    "); + + $markup = substr_replace($markup, '', $position, 4); + } + + return $markup; + } + + # + # Deprecated Methods + # + + function parse($text) + { + $markup = $this->text($text); + + return $markup; + } + + protected function sanitiseElement(array $Element) + { + static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; + static $safeUrlNameToAtt = array( + 'a' => 'href', + 'img' => 'src', + ); + + if (isset($safeUrlNameToAtt[$Element['name']])) + { + $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); + } + + if ( ! empty($Element['attributes'])) + { + foreach ($Element['attributes'] as $att => $val) + { + # filter out badly parsed attribute + if ( ! preg_match($goodAttribute, $att)) + { + unset($Element['attributes'][$att]); + } + # dump onevent attribute + elseif (self::striAtStart($att, 'on')) + { + unset($Element['attributes'][$att]); + } + } + } + + return $Element; + } + + protected function filterUnsafeUrlInAttribute(array $Element, $attribute) + { + foreach ($this->safeLinksWhitelist as $scheme) + { + if (self::striAtStart($Element['attributes'][$attribute], $scheme)) + { + return $Element; + } + } + + $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); + + return $Element; + } + + # + # Static Methods + # + + protected static function escape($text, $allowQuotes = false) + { + return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); + } + + protected static function striAtStart($string, $needle) + { + $len = strlen($needle); + + if ($len > strlen($string)) + { + return false; + } + else + { + return strtolower(substr($string, 0, $len)) === strtolower($needle); + } + } + + static function instance($name = 'default') + { + if (isset(self::$instances[$name])) + { + return self::$instances[$name]; + } + + $instance = new static(); + + self::$instances[$name] = $instance; + + return $instance; + } + + private static $instances = array(); + + # + # Fields + # + + protected $DefinitionData; + + # + # Read-Only + + protected $specialCharacters = array( + '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', + ); + + protected $StrongRegex = array( + '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', + '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', + ); + + protected $EmRegex = array( + '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', + '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', + ); + + protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; + + protected $voidElements = array( + 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', + ); + + protected $textLevelElements = array( + 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', + 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', + 'i', 'rp', 'del', 'code', 'strike', 'marquee', + 'q', 'rt', 'ins', 'font', 'strong', + 's', 'tt', 'kbd', 'mark', + 'u', 'xm', 'sub', 'nobr', + 'sup', 'ruby', + 'var', 'span', + 'wbr', 'time', + ); +} diff --git a/inc/categories-images.php b/inc/categories-images.php new file mode 100644 index 0000000..06e65cf --- /dev/null +++ b/inc/categories-images.php @@ -0,0 +1,237 @@ + + th.column-thumb {width:60px;} + .form-field img.taxonomy-image {border:1px solid #eee;max-width:300px;max-height:300px;} + .inline-edit-row fieldset .thumb label span.title {width:48px;height:48px;border:1px solid #eee;display:inline-block;} + .column-thumb span {width:48px;height:48px;border:1px solid #eee;display:inline-block;} + .inline-edit-row fieldset .thumb img,.column-thumb img {width:48px;height:48px;} + '; +} + +// 添加在添加窗体中的图像字段 +function z_add_texonomy_field() { + if (get_bloginfo('version') >= 3.5) // worpdress 最低版本3.5 + wp_enqueue_media(); + else { + wp_enqueue_style('thickbox'); + wp_enqueue_script('thickbox'); + } + + echo '
    + + +
    + +
    '.z_script(); +} + +// 在编辑窗体中添加图像字段 +function z_edit_texonomy_field($taxonomy) { + if (get_bloginfo('version') >= 3.5) + wp_enqueue_media(); + else { + wp_enqueue_style('thickbox'); + wp_enqueue_script('thickbox'); + } + + if (z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ) == Z_IMAGE_PLACEHOLDER) + $image_url = ""; + else + $image_url = z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ); + echo ' + +

    + + + + '.z_script(); +} + +// 上传图像 +function z_script() { + return ''; +} + +// 添加到钩子 +add_action('edit_term','z_save_taxonomy_image'); +add_action('create_term','z_save_taxonomy_image'); +function z_save_taxonomy_image($term_id) { + if(isset($_POST['taxonomy_image'])) + update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image'], NULL); +} + +// 附件地址 +function z_get_attachment_id_by_url($image_src) { + global $wpdb; + $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid = %s", $image_src); + $id = $wpdb->get_var($query); + return (!empty($id)) ? $id : NULL; +} + +// 我不知道 +function z_taxonomy_image_url($term_id = NULL, $size = 'full', $return_placeholder = FALSE) { + if (!$term_id) { + if (is_category()) + $term_id = get_query_var('cat'); + elseif (is_tag()) + $term_id = get_query_var('tag_id'); + elseif (is_tax()) { + $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); + $term_id = $current_term->term_id; + } + } + + $taxonomy_image_url = get_option('z_taxonomy_image'.$term_id); + if(!empty($taxonomy_image_url)) { + $attachment_id = z_get_attachment_id_by_url($taxonomy_image_url); + if(!empty($attachment_id)) { + $taxonomy_image_url = wp_get_attachment_image_src($attachment_id, $size); + $taxonomy_image_url = $taxonomy_image_url[0]; + } + } + + if ($return_placeholder) + return ($taxonomy_image_url != '') ? $taxonomy_image_url : Z_IMAGE_PLACEHOLDER; + else + return $taxonomy_image_url; +} + +function z_quick_edit_custom_box($column_name, $screen, $name) { + if ($column_name == 'thumb') + echo '
    +
    + +
    +
    '; +} + +/** + * 添加类别管理 + */ +function z_taxonomy_columns( $columns ) { + $new_columns = array(); + $new_columns['cb'] = $columns['cb']; + $new_columns['thumb'] = __('图像', 'categories-images'); + + unset( $columns['cb'] ); + + return array_merge( $new_columns, $columns ); +} + +/** + * 图像列表 + */ +function z_taxonomy_column( $columns, $column, $id ) { + if ( $column == 'thumb' ) + $columns = '' . __('暂无', 'categories-images') . ''; + + return $columns; +} + +// 将“插入帖子”更改为“使用此图片” +function z_change_insert_button_text($safe_text, $text) { + return str_replace("Insert into Post", "Use this image", $text); +} + +// 列表图片样式 +if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) { + add_action('quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3); + add_filter("attribute_escape", "z_change_insert_button_text", 10, 2); +} diff --git a/inc/css/admin.css b/inc/css/admin.css new file mode 100644 index 0000000..c300988 --- /dev/null +++ b/inc/css/admin.css @@ -0,0 +1,46 @@ +.theme-about { + background: #fff; + max-width:860px; + margin: 0 auto; + box-shadow: 0 2px 6px rgba(0,0,0,.04); + border: 1px solid #ddd; + margin-top:50px +} +.fu-info { + padding:20px 40px +} +.fu-info p { + line-height: 30px; + font-size: 15px; + color: #797979; + letter-spacing: 2px; +} + +.fu-she { + text-align: center; + margin-bottom: 30px; + display: inline-block; + width: 100%; + padding:20px 0 +} +.fu-she span { + margin-right:15px +} +.akina img { + width: 50px; +} +.fufooter-info { + height: 70px; + background: #384152; + margin-top:20px +} +span.copyright-fu { + width: 100%; + display: inline-block; + padding: 25px 0; + text-align: center; + color: white; +} +.fufooter-info a{ + color:#fff +} \ No newline at end of file diff --git a/inc/css/color-picker.min.css b/inc/css/color-picker.min.css new file mode 100644 index 0000000..337f2ed --- /dev/null +++ b/inc/css/color-picker.min.css @@ -0,0 +1 @@ +.wp-color-picker{width:80px}.wp-picker-container .hidden{display:none}.wp-color-result{background-color:#f9f9f9;border:1px solid #bbb;border-radius:2px;cursor:pointer;display:inline-block;height:22px;margin:0 6px 6px 0;position:relative;top:1px;user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;vertical-align:bottom;display:inline-block;padding-left:30px}.wp-color-result:after{background:#f3f3f3;background-image:-webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#f4f4f4));background-image:-webkit-linear-gradient(top,#fefefe,#f4f4f4);background-image:-moz-linear-gradient(top,#fefefe,#f4f4f4);background-image:-o-linear-gradient(top,#fefefe,#f4f4f4);background-image:linear-gradient(to bottom,#fefefe,#f4f4f4);color:#333;text-shadow:0 1px 0 #fff;border-radius:0 1px 1px 0;border-left:1px solid #bbb;content:attr(title);display:block;font-size:11px;line-height:22px;padding:0 6px;position:relative;right:0;text-align:center;top:0}.wp-color-result:hover{border-color:#aaa;box-shadow:0 1px 1px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.1);-ms-box-shadow:0 1px 1px rgba(0,0,0,0.1);-o-box-shadow:0 1px 1px rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.1)}.wp-color-result:hover:after{color:#222;border-color:#aaa;border-left:1px solid #999}.wp-color-result.wp-picker-open{top:0}.wp-color-result.wp-picker-open:after{content:attr(data-current)}.wp-picker-container,.wp-picker-container:active{display:inline-block;outline:0}.wp-color-result:focus{border-color:#888;-moz-box-shadow:0 1px 2px rgba(0,0,0,0.2);-ms-box-shadow:0 1px 2px rgba(0,0,0,0.2);-o-box-shadow:0 1px 2px rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.2);box-shadow:0 1px 2px rgba(0,0,0,0.2)}.wp-color-result:focus:after{border-color:#888}.wp-picker-open+.wp-picker-input-wrap{display:inline-block;vertical-align:top}.wp-picker-container .button{margin-left:6px}.wp-picker-container .iris-square-slider .ui-slider-handle:focus{background-color:#555}.wp-picker-container .iris-picker{border-color:#dfdfdf;margin-top:6px}input[type="text"].iris-error{background-color:#ffebe8;border-color:#c00;color:#000} \ No newline at end of file diff --git a/inc/css/dashboard-light.css b/inc/css/dashboard-light.css new file mode 100644 index 0000000..005a9aa --- /dev/null +++ b/inc/css/dashboard-light.css @@ -0,0 +1,155 @@ +body { + background-image: url(https://view.moezx.cc/images/2018/01/29/FLOWER.jpg) !important; +} + +#adminmenu, #adminmenuback, #adminmenuwrap { + background: #e5e5e590 !important; +} + +#wpadminbar { + background: #e5e5e5 !important; +} + +#adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, #adminmenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu { + background: #ffffff90 !important; +} + +.wp-submenu-wrap { + background: #ffffff99 !important; +} + +.postbox { + min-width: 255px; + border: 1px solid #e5e5e5; + background: #ffffff90 !important; +} + +#contextual-help-link-wrap, #screen-options-link-wrap { + background: #e5e5e5 !important; +} + +table { + background: #ffffff90 !important; +} + +tr { + background-color: #ffffff00 !important; +} + +#screen-meta { + background-color: #ffffff90 !important; +} + +.notice, div.error, div.updated { + background: #ffffff90; +} + +#dolly { + background: rgba(255,255,255,.7); + border-left: 4px solid #fff; + border-left-color: rgb(255, 255, 255); + box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); + border-left-color: #888; + font-size: 13px; + padding: 6px; + padding-right: 15px; + padding-top: 5px; + float: none !important; + width: calc(100% - 46px); +} + +#adminmenu a, #adminmenu .wp-submenu .wp-submenu-head, #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, #adminmenu .wp-menu-arrow, #adminmenu .wp-menu-arrow div, #adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, .folded #adminmenu li.current.menu-top, .folded #adminmenu li.wp-has-current-submenu { + color: #333; +} + +.gadwp-pline a { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + position: absolute; + width: 80%; +} + +.wp-submenu .wp-submenu-wrap { + background: #ffffff !important; +} + +// emotion; +/*bilibili*/ +.emotion-box { + padding-left: 16px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + display: none; +} +.emotion-inline { + padding-left: 0px !important; + padding-right: 0px !important; +} +.emotion-item { + margin: 6px; + display: inline-block; + width: 32px; + height: 32px; + overflow: hidden; + border-radius: 4px; + margin-bottom: -8px; +} +.emotion-secter { + margin: 12px 12px 0 0; +} +@media (max-width: 860px) { + .emotion-box { + padding-left: 0; + } + .emotion-item { + transform: scale(0.6); + margin-bottom: -10px; + } + .emotion-secter { + margin: 0; + } +} + +.emotion-item .img { + -webkit-animation: im-emotion-step 1.08s steps(27) infinite; + animation: im-emotion-step 1.08s steps(27) infinite; + animation-duration: 1.08s; + animation-timing-function: steps(27); +} + +.emotion-item .img { + width: 32px; + height: 864px; + max-width: 32px; + background: top/32px no-repeat; + background-image: none; +} + +@-webkit-keyframes im-emotion-step { + 0% { + -webkit-transform:translateY(0); + transform:translateY(0) + } + to { + -webkit-transform:translateY(-100%); + transform:translateY(-100%) + } +} +@keyframes im-emotion-step { + 0% { + -webkit-transform:translateY(0); + transform:translateY(0) + } + to { + -webkit-transform:translateY(-100%); + transform:translateY(-100%) + } +} \ No newline at end of file diff --git a/inc/css/optionsframework.css b/inc/css/optionsframework.css new file mode 100644 index 0000000..3a8fe9c --- /dev/null +++ b/inc/css/optionsframework.css @@ -0,0 +1,458 @@ +/* Options Framework Admin Styles */ + +body { + font-family:miranafont,"Hiragino Sans GB",STXihei,"Microsoft YaHei",SimSun,sans-serif; + background:#F5F5F5 ; + height: auto; +} + +.nav-tab-wrapper { + position: relative; + max-width: 860px; + margin: auto !important; +} + +.wrap h2.nav-tab-wrapper { + border-bottom:none +} + +.metabox-holder { + padding-top:0 !important +} + +.nav-tab-active { + border-bottom: none; + background: #fff; + color: #000; + border:none; + font-weight: 300; + font-size: 18px; + color: #4B6894; +} + +.nav-tab-active:hover { + background: #fff; +} + +.nav-tab { + background: none; + border:none; + padding: 10px 20px; + font-weight: 300; + font-size: 15px; + color: darkgoldenrod; + border-radius: 3px 3px 0 0; +} + +.nav-tab-active { + background:#fff +} + +a#options-group-1-tab:before { + font-family: "dashicons"; + content: "\f111"; + float: left; +} + +a#options-group-2-tab:before { + font-family: "dashicons"; + content: "\f102"; + float: left; +} + +a#options-group-3-tab:before { + font-family: "dashicons"; + content: "\f123"; + float: left; +} + +a#options-group-4-tab:before { + font-family: "dashicons"; + content: "\f487"; + float: left; +} + +a#options-group-5-tab:before { + font-family: "dashicons"; + content: "\f227"; + float: left; +} + +a#options-group-6-tab:before { + font-family: "dashicons"; + content: "\f105"; + float: left; +} + +a#options-group-7-tab:before { /*前台登陆*/ + font-family: "dashicons"; + content: "\f110"; + float: left; +} + +a#options-group-8-tab:before { /*CDN*/ + font-family: "dashicons"; + content: "\f325"; + float: left; +} + +a#options-group-9-tab:before { /*Mashiro*/ + font-family: "dashicons"; + content: "\f487"; + float: left; +} + +input[type=checkbox], input[type=radio] { + border: 1px solid #b4b9be; + background: #fff; + color: #555; + clear: none; + cursor: pointer; + display: inline-block; + line-height: 0; + height: 16px; + margin: -4px 4px 0 0; + outline: none; + padding: 0!important; + text-align: center; + vertical-align: middle; + width: 16px; + min-width: 16px; + box-shadow: none +} + +input[type="button"]{ + box-shadow: none !important; + border: none !important; + background:#FF5858 !important; + color:#fff !important +} + +input[type=text], +input[type=password], +input[type=checkbox], +input[type=color], +input[type=date], +input[type=datetime], +input[type=datetime-local], +input[type=email], +input[type=month], +input[type=number], +input[type=radio], +input[type=tel], +input[type=time], +input[type=url], +input[type=week], +input[type=search], +select, textarea{ + box-shadow:none +} +input[type="submit" i], input[type="reset" i]{ + +} + +#optionsframework h4 { + font-weight:300; + font-size: 15px +} +#optionsframework { + position:relative; + z-index: 0; + max-width:860px; + background:#FBFBFB; + padding: 30px; + margin: auto; + box-shadow: none; + border: none; + border: 1px solid #fff; + border-radius: 3px; +} +#optionsframework h3 { + cursor: default; + cursor: default; + font-size: 20px; + font-weight: 600; + color: #3F607D; + display: none; +} +#optionsframework p { + margin-bottom:0; + padding-bottom:10px; + line-height: 1.4em; +} +#optionsframework .section { + padding: 10px; + margin-bottom: 20px; + padding-bottom: 30px; + border-bottom: 1px solid #E8E8E8; +} +#optionsframework .group { + padding-bottom:40px; +} +#optionsframework .section .heading { + padding:10px 0px; + margin:0 0 15px; + font-weight: 600; + color: #455E8C; +} +#optionsframework .section .controls { + float: left; + min-width:350px; + width: 54%; + padding-right:2%; +} +#optionsframework .section .explain { + max-width:38%; + float: left; + font-size: 12px; + line-height:20px; + color: #777; +} +#optionsframework .section-checkbox .controls { + width: 98%; +} +#optionsframework .section-checkbox .explain { + max-width:94%; +} +#optionsframework .of-input { + width:100%; +} +#optionsframework .controls select, #optionsframework .controls textarea { + margin-bottom:10px; + width:100%; +} +#optionsframework .section-radio label, #optionsframework .section-multicheck label { + float:left; + max-width:90%; + line-height: 16px; + margin-bottom: 5px; +} +#optionsframework input.checkbox, #optionsframework input.of-radio { + width: 15px; + margin-top:2px; + float:left; + clear:both; + border-radius: 50%; +} +#optionsframework .section-typography .controls { + float:none; + width:auto; +} +#optionsframework .section-typography .explain { + float:none; + width:auto; +} +#optionsframework .controls .of-typography-size { + width:80px; + float:left +} +#optionsframework .controls .of-typography-unit { + width:50px; + margin-left:5px; + float:left +} +#optionsframework .controls .of-typography-face { + width:100px; + margin-left:5px; + float:left +} +#optionsframework .controls .of-typography-style { + width:80px; + margin-left:5px; + margin-right:5px; + float:left +} +#optionsframework .of-background-properties { + clear:both; + margin-top: 18px; +} +#optionsframework .controls .of-background-repeat { + width:125px; + margin-right:5px; + float:left +} +#optionsframework .controls .of-background-position { + width:125px; + margin-right:5px; + float:left +} +#optionsframework .controls .of-background-attachment { + width:125px; + margin-right:5px; + float:left +} +#optionsframework .section-background .wp-picker-container { + margin-bottom:10px; +} +#optionsframework .controls .of-radio-img-img { + border:3px solid #f9f9f9; + margin:0 5px 10px 0; + display:none; + cursor:pointer; + float:left; +} +#optionsframework .controls .of-radio-img-selected { + border:3px solid #ccc +} +#optionsframework .controls .of-radio-img-img:hover { + opacity:.8; +} +#optionsframework .controls .of-border-width { + width:80px; + float:left +} +#optionsframework .controls .of-border-style { + width:120px; + float:left +} +#optionsframework .hide { + display:none; +} +#optionsframework .of-option-image { + max-width:340px; + margin:3px 0 18px 0; +} +#optionsframework .mini .controls select, #optionsframework .section .mini .controls { + width: 140px; +} +#optionsframework .mini .controls input, #optionsframework .mini .controls { + min-width:140px; + width: 140px; +} +#optionsframework .mini .explain { + max-width:74%; +} + +/* Editor */ + +#optionsframework .section-editor .explain { + max-width: 98%; + float:none; + margin-bottom:5px; +} + +/* Image Uploader */ + +#optionsframework .controls input.upload { + width:80%; + box-shadow: none; +} +#optionsframework .controls input.upload_button { + float:right; + border-color:#BBBBBB; + cursor:pointer; +} +#optionsframework .controls input.upload_button:hover { + border-color:#666666; + color:#000; +} +#optionsframework .screenshot { + float:left; + margin-left:1px; + position:relative; + width:150px; + margin-top:20px; +} +#optionsframework .screenshot img { + background:#FAFAFA; + border-color:#ccc #eee #eee #ccc; + border-style:solid; + border-width:1px; + float:left; + max-width:334px; + max-height: 130px; + padding:4px; + margin-bottom:10px; +} +#optionsframework .screenshot .remove-image { + background:url("../images/ico-delete.png") no-repeat; + border:medium none; + bottom:4px; + display:block; + float:left; + height:16px; + padding:0; + position:absolute; + left:-4px; + text-indent:-9999px; + width:16px; +} +#optionsframework .screenshot .no_image .file_link { + margin-left: 20px; +} +#optionsframework .screenshot .no_image .remove-button { + bottom: 0px; +} +#optionsframework .reset-button { + float: left; + box-shadow: none; + border: none; + background: #374D6F; + text-shadow: none; + color:#fff; + height: 40px; + width: 100px; + border-radius: 0px; + cursor:pointer; +} + +/* Bottom Section */ + +#optionsframework-submit { + padding: 7px 10px; + background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC); +} +#optionsframework .button-primary { + float: right; + box-shadow: none; + border: none; + background: #FF6464; + text-shadow: none; + /* padding: 10px; */ + height: 40px; + width: 100px; + border-radius: 0px; +} +#optionsframework .section:after { + content: ""; + display: table; +} +#optionsframework .section:after { + clear: both; +} + +input.of-radio-img-radio{display: none;} +.of-radio-img-label{display: none;} +.of-radio-color{ + display: inline-block;width: 20px;height: 20px;margin: 0 5px 0 0; +} +#optionsframework .controls .of-radio-img-img { + border:3px solid #f9f9f9; + margin:0 5px 10px 0; + /*display:none;*/ + cursor:pointer; + float:left; +} +#optionsframework .controls .of-radio-img-selected { + border:3px solid #ccc +} +#optionsframework .controls .of-radio-img-img:hover { + opacity:.8; +} +#optionsframework .controls .of-border-width { + width:80px; + float:left +} +#optionsframework .controls .of-border-style { + width:120px; + float:left +} + + +#optionsframework .section-color .controls, +#optionsframework .section-colorradio .controls, +#optionsframework .section-radio .controls{float: none;width: 100%;overflow: hidden;margin-bottom: 5px;} + +#optionsframework .section-color .explain, +#optionsframework .section-colorradio .explain, +#optionsframework .section-radio .explain{float: none;width: 100%;} diff --git a/inc/customizer.php b/inc/customizer.php new file mode 100644 index 0000000..49bb83e --- /dev/null +++ b/inc/customizer.php @@ -0,0 +1,26 @@ +get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; + $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; +} +add_action( 'customize_register', 'akina_customize_register' ); + +/** + * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. + */ +function akina_customize_preview_js() { + wp_enqueue_script( 'akina_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); +} +add_action( 'customize_preview_init', 'akina_customize_preview_js' ); diff --git a/inc/decorate.php b/inc/decorate.php new file mode 100644 index 0000000..53a3d05 --- /dev/null +++ b/inc/decorate.php @@ -0,0 +1,48 @@ + + + \ No newline at end of file diff --git a/inc/fonts/SAKURASO.old/sakuraso.eot b/inc/fonts/SAKURASO.old/sakuraso.eot new file mode 100644 index 0000000..abdcfc5 Binary files /dev/null and b/inc/fonts/SAKURASO.old/sakuraso.eot differ diff --git a/inc/fonts/SAKURASO.old/sakuraso.svg b/inc/fonts/SAKURASO.old/sakuraso.svg new file mode 100644 index 0000000..d8931a4 --- /dev/null +++ b/inc/fonts/SAKURASO.old/sakuraso.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/inc/fonts/SAKURASO.old/sakuraso.ttf b/inc/fonts/SAKURASO.old/sakuraso.ttf new file mode 100644 index 0000000..81c2dbe Binary files /dev/null and b/inc/fonts/SAKURASO.old/sakuraso.ttf differ diff --git a/inc/fonts/SAKURASO.old/sakuraso.woff b/inc/fonts/SAKURASO.old/sakuraso.woff new file mode 100644 index 0000000..0bcfb19 Binary files /dev/null and b/inc/fonts/SAKURASO.old/sakuraso.woff differ diff --git a/inc/fonts/iconfont.eot b/inc/fonts/iconfont.eot new file mode 100644 index 0000000..12aa257 Binary files /dev/null and b/inc/fonts/iconfont.eot differ diff --git a/inc/fonts/iconfont.svg b/inc/fonts/iconfont.svg new file mode 100644 index 0000000..ec19f6f --- /dev/null +++ b/inc/fonts/iconfont.svg @@ -0,0 +1,226 @@ + + + + +Created by FontForge 20120731 at Mon Apr 25 21:38:11 2016 + By admin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inc/fonts/iconfont.ttf b/inc/fonts/iconfont.ttf new file mode 100644 index 0000000..792069b Binary files /dev/null and b/inc/fonts/iconfont.ttf differ diff --git a/inc/fonts/iconfont.woff b/inc/fonts/iconfont.woff new file mode 100644 index 0000000..b9fee8c Binary files /dev/null and b/inc/fonts/iconfont.woff differ diff --git a/inc/images/ico-delete.png b/inc/images/ico-delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/inc/images/ico-delete.png differ diff --git a/inc/js/addtohomescreen.js b/inc/js/addtohomescreen.js new file mode 100644 index 0000000..dabcfc8 --- /dev/null +++ b/inc/js/addtohomescreen.js @@ -0,0 +1,750 @@ +/* Add to Homescreen v3.2.3 ~ (c) 2015 Matteo Spinelli ~ @license: http://cubiq.org/license */ +(function (window, document) { +/* + _ _ _____ _____ + ___ _| |_| |_ _|___| | |___ _____ ___ ___ ___ ___ ___ ___ ___ +| .'| . | . | | | | . | | . | | -_|_ -| _| _| -_| -_| | +|__,|___|___| |_| |___|__|__|___|_|_|_|___|___|___|_| |___|___|_|_| + by Matteo Spinelli ~ http://cubiq.org +*/ + +// Check for addEventListener browser support (prevent errors in IE<9) +var _eventListener = 'addEventListener' in window; + +// Check if document is loaded, needed by autostart +var _DOMReady = false; +if ( document.readyState === 'complete' ) { + _DOMReady = true; +} else if ( _eventListener ) { + window.addEventListener('load', loaded, false); +} + +function loaded () { + window.removeEventListener('load', loaded, false); + _DOMReady = true; +} + +// regex used to detect if app has been added to the homescreen +var _reSmartURL = /\/ath(\/)?$/; +var _reQueryString = /([\?&]ath=[^&]*$|&ath=[^&]*(&))/; + +// singleton +var _instance; +function ath (options) { + _instance = _instance || new ath.Class(options); + + return _instance; +} + +// message in all supported languages +ath.intl = { + cs_cs: { + ios: 'Pro přidáni této webové aplikace na úvodní obrazovku: stlačte %icon a pak Přidat na úvodní obrazovku.', + android: 'Pro přidáni této webové aplikace na úvodní obrazovku otevřete menu nastavení prohlížeče a stlačte Přidat na úvodní obrazovku. K menu se dostanete stlačením hardwaroveho tlačítka, když ho vaše zařízení má, nebo stlačením pravé horní menu ikony icon.' + }, + + de_de: { + ios: 'Um diese Web-App zum Home-Bildschirm hinzuzufügen, tippen Sie auf %icon und dann Zum Home-Bildschirm.', + android: 'Um diese Web-App zum Home-Bildschirm hinzuzufügen, öffnen Sie das Menü und tippen dann auf Zum Startbildschirm hinzufügen. Wenn Ihr Gerät eine Menütaste hat, lässt sich das Browsermenü über diese öffnen. Ansonsten tippen Sie auf %icon.' + }, + + da_dk: { + ios: 'For at tilføje denne web app til hjemmeskærmen: Tryk %icon og derefter Føj til hjemmeskærm.', + android: 'For at tilføje denne web app til hjemmeskærmen, åbn browser egenskaber menuen og tryk på Føj til hjemmeskærm. Denne menu kan tilgås ved at trykke på menu knappen, hvis din enhed har en, eller ved at trykke på det øverste højre menu ikon %icon.' + }, + + el_gr: { + ios: 'Για να προσθέσετε την εφαρμογή στην αρχική οθόνη: πατήστε το %icon και μετά Πρόσθεσε στην αρχική οθόνη.', + android: 'Για να προσθέσετε την εφαρμογή στην αρχική οθόνη, ανοίξτε τις επιλογές του browser σας και πατήστε το Προσθήκη στην αρχική οθόνη. Μπορείτε να έχετε πρόσβαση στο μενού, πατώντας το κουμπί του μενού του κινητού σας ή το πάνω δεξιά κουμπί του μενού %icon.' + }, + + en_us: { + ios: 'To add this web app to the home screen: tap %icon and then Add to Home Screen.', + android: 'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon %icon.' + }, + + es_es: { + ios: 'Para añadir esta aplicación web a la pantalla de inicio: pulsa %icon y selecciona Añadir a pantalla de inicio.', + android: 'Para añadir esta aplicación web a la pantalla de inicio, abre las opciones y pulsa Añadir a pantalla inicio. El menú se puede acceder pulsando el botón táctil en caso de tenerlo, o bien el icono de la parte superior derecha de la pantalla %icon.' + }, + + fi_fi: { + ios: 'Liitä tämä sovellus kotivalikkoon: klikkaa %icon ja tämän jälkeen Lisää kotivalikkoon.', + android: 'Lisätäksesi tämän sovelluksen aloitusnäytölle, avaa selaimen valikko ja klikkaa tähti -ikonia tai Lisää aloitusnäytölle tekstiä. Valikkoon pääsee myös painamalla menuvalikkoa, jos laitteessasi on sellainen tai koskettamalla oikealla yläkulmassa menu ikonia %icon.' + }, + + fr_fr: { + ios: 'Pour ajouter cette application web sur l\'écran d\'accueil : Appuyez %icon et sélectionnez Ajouter sur l\'écran d\'accueil.', + android: 'Pour ajouter cette application web sur l\'écran d\'accueil : Appuyez sur le bouton "menu", puis sur Ajouter sur l\'écran d\'accueil. Le menu peut-être accessible en appuyant sur le bouton "menu" du téléphone s\'il en possède un . Sinon, il se trouve probablement dans la coin supérieur droit du navigateur %icon.' + }, + + he_il: { + ios: 'להוספת האפליקציה למסך הבית: ללחוץ על %icon ואז הוסף למסך הבית.', + android: 'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon %icon.' + }, + + hu_hu: { + ios: 'Ha hozzá szeretné adni ezt az alkalmazást a kezdőképernyőjéhez, érintse meg a következő ikont: %icon , majd a Hozzáadás a kezdőképernyőhöz menüpontot.', + android: 'Ha hozzá szeretné adni ezt az alkalmazást a kezdőképernyőjéhez, a böngésző menüjében kattintson a Hozzáadás a kezdőképernyőhöz menüpontra. A böngésző menüjét a következő ikon megérintésével tudja megnyitni: %icon.' + }, + + it_it: { + ios: 'Per aggiungere questa web app alla schermata iniziale: premi %icon e poi Aggiungi a Home.', + android: 'Per aggiungere questa web app alla schermata iniziale, apri il menu opzioni del browser e premi su Aggiungi alla homescreen. Puoi accedere al menu premendo il pulsante hardware delle opzioni se la tua device ne ha uno, oppure premendo l\'icona %icon in alto a destra.' + }, + + ja_jp: { + ios: 'このウェプアプリをホーム画面に追加するには、%iconをタップしてホーム画面に追加してください。', + android: 'このウェプアプリをホーム画面に追加するには、ブラウザのオプションメニューからホーム画面に追加をタップしてください。オプションメニューは、一部の機種ではデバイスのメニューボタンから、それ以外では画面右上の%iconからアクセスできます。' + }, + + ko_kr: { + ios: '홈 화면에 바로가기 생성: %icon 을 클릭한 후 홈 화면에 추가.', + android: '브라우저 옵션 메뉴의 홈 화면에 추가를 클릭하여 홈화면에 바로가기를 생성할 수 있습니다. 옵션 메뉴는 장치의 메뉴 버튼을 누르거나 오른쪽 상단의 메뉴 아이콘 %icon을 클릭하여 접근할 수 있습니다.' + }, + + nb_no: { + ios: 'For å installere denne appen på hjem-skjermen: trykk på %icon og deretter Legg til på Hjem-skjerm.', + android: 'For å legge til denne webappen på startsiden åpner en nettlesermenyen og velger Legg til på startsiden. Menyen åpnes ved å trykke på den fysiske menyknappen hvis enheten har det, eller ved å trykke på menyikonet øverst til høyre %icon.' + }, + + pt_br: { + ios: 'Para adicionar este app à tela de início: clique %icon e então Tela de início.', + android: 'Para adicionar este app à tela de início, abra o menu de opções do navegador e selecione Adicionar à tela inicial. O menu pode ser acessado pressionando o "menu" button se o seu dispositivo tiver um, ou selecionando o ícone %icon no canto superior direito.' + }, + + pt_pt: { + ios: 'Para adicionar esta app ao ecrã principal: clique %icon e depois Ecrã principal.', + android: 'Para adicionar esta app web ecrã principal, abra o menu de opções do navegador e selecione Adicionar à tela inicial. O menu pode ser acessado pressionando o "menu" button se o seu dispositivo tiver um, ou selecionando o ícone %icon no canto superior direito.' + }, + + nl_nl: { + ios: 'Om deze webapp aan je startscherm toe te voegen, klik op %icon en dan Zet in startscherm.', + android: 'Om deze webapp aan je startscherm toe te voegen, open de browserinstellingen en tik op Toevoegen aan startscherm. Gebruik de "menu" knop als je telefoon die heeft, anders het menu-icoon rechtsbovenin %icon.' + }, + + ru_ru: { + ios: 'Чтобы добавить этот сайт на свой домашний экран, нажмите на иконку %icon и затем На экран "Домой".', + android: 'Чтобы добавить сайт на свой домашний экран, откройте меню браузера и нажмите на Добавить на главный экран. Меню можно вызвать, нажав на кнопку меню вашего телефона, если она есть. Или найдите иконку сверху справа %icon[иконка].' + }, + + sk_sk: { + ios: 'Pre pridanie tejto webovej aplikácie na úvodnú obrazovku: stlačte %icon a potom Pridať na úvodnú obrazovku.', + android: 'Pre pridanie tejto webovej aplikácie na úvodnú obrazovku otvorte menu nastavenia prehliadača a stlačte Pridať na úvodnú obrazovku. K menu sa dostanete stlačením hardwaroveho tlačidla, ak ho vaše zariadenie má, alebo stlačením pravej hornej menu ikony icon.' + }, + + sv_se: { + ios: 'För att lägga till denna webbapplikation på hemskärmen: tryck på %icon och därefter Lägg till på hemskärmen.', + android: 'För att lägga till den här webbappen på hemskärmen öppnar du webbläsarens alternativ-meny och väljer Lägg till på startskärmen. Man hittar menyn genom att trycka på hårdvaruknappen om din enhet har en sådan, eller genom att trycka på menyikonen högst upp till höger %icon.' + }, + + tr_tr: { + ios: 'Uygulamayı ana ekrana eklemek için, %icon ve ardından ana ekrana ekle butonunu tıklayın.', + android: 'Uygulamayı ana ekrana eklemek için, menüye girin ve ana ekrana ekle butonunu tıklayın. Cihazınız menü tuşuna sahip ise menüye girmek için menü tuşunu tıklayın. Aksi takdirde %icon butonunu tıklayın.' + }, + + uk_ua: { + ios: 'Щоб додати цей сайт на початковий екран, натисніть %icon, а потім На початковий екран.', + android: 'Щоб додати цей сайт на домашній екран, відкрийте меню браузера та виберіть Додати на головний екран. Це можливо зробити, натиснувши кнопку меню на вашому смартфоні, якщо така є. Або ж на іконці зверху справа %icon.' + }, + + zh_cn: { + ios: '如要把应用程序加至主屏幕,请点击%icon, 然后添加到主屏幕', + android: 'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon %icon.' + }, + + zh_tw: { + ios: '如要把應用程式加至主屏幕, 請點擊%icon, 然後加至主屏幕.', + android: 'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon %icon.' + } +}; + +// Add 2 characters language support (Android mostly) +for ( var lang in ath.intl ) { + ath.intl[lang.substr(0, 2)] = ath.intl[lang]; +} + +// default options +ath.defaults = { + appID: 'org.cubiq.addtohome', // local storage name (no need to change) + fontSize: 15, // base font size, used to properly resize the popup based on viewport scale factor + debug: false, // override browser checks + logging: false, // log reasons for showing or not showing to js console; defaults to true when debug is true + modal: false, // prevent further actions until the message is closed + mandatory: false, // you can't proceed if you don't add the app to the homescreen + autostart: true, // show the message automatically + skipFirstVisit: false, // show only to returning visitors (ie: skip the first time you visit) + startDelay: 1, // display the message after that many seconds from page load + lifespan: 15, // life of the message in seconds + displayPace: 1440, // minutes before the message is shown again (0: display every time, default 24 hours) + maxDisplayCount: 0, // absolute maximum number of times the message will be shown to the user (0: no limit) + icon: true, // add touch icon to the message + message: '', // the message can be customized + validLocation: [], // list of pages where the message will be shown (array of regexes) + onInit: null, // executed on instance creation + onShow: null, // executed when the message is shown + onRemove: null, // executed when the message is removed + onAdd: null, // when the application is launched the first time from the homescreen (guesstimate) + onPrivate: null, // executed if user is in private mode + privateModeOverride: false, // show the message even in private mode (very rude) + detectHomescreen: false // try to detect if the site has been added to the homescreen (false | true | 'hash' | 'queryString' | 'smartURL') +}; + +// browser info and capability +var _ua = window.navigator.userAgent; + +var _nav = window.navigator; +_extend(ath, { + hasToken: document.location.hash == '#ath' || _reSmartURL.test(document.location.href) || _reQueryString.test(document.location.search), + isRetina: window.devicePixelRatio && window.devicePixelRatio > 1, + isIDevice: (/iphone|ipod|ipad/i).test(_ua), + isMobileChrome: _ua.indexOf('Android') > -1 && (/Chrome\/[.0-9]*/).test(_ua) && _ua.indexOf("Version") == -1, + isMobileIE: _ua.indexOf('Windows Phone') > -1, + language: _nav.language && _nav.language.toLowerCase().replace('-', '_') || '' +}); + +// falls back to en_us if language is unsupported +ath.language = ath.language && ath.language in ath.intl ? ath.language : 'en_us'; + +ath.isMobileSafari = ath.isIDevice && _ua.indexOf('Safari') > -1 && _ua.indexOf('CriOS') < 0; +ath.OS = ath.isIDevice ? 'ios' : ath.isMobileChrome ? 'android' : ath.isMobileIE ? 'windows' : 'unsupported'; + +ath.OSVersion = _ua.match(/(OS|Android) (\d+[_\.]\d+)/); +ath.OSVersion = ath.OSVersion && ath.OSVersion[2] ? +ath.OSVersion[2].replace('_', '.') : 0; + +ath.isStandalone = 'standalone' in window.navigator && window.navigator.standalone; +ath.isTablet = (ath.isMobileSafari && _ua.indexOf('iPad') > -1) || (ath.isMobileChrome && _ua.indexOf('Mobile') < 0); + +ath.isCompatible = (ath.isMobileSafari && ath.OSVersion >= 6) || ath.isMobileChrome; // TODO: add winphone + +var _defaultSession = { + lastDisplayTime: 0, // last time we displayed the message + returningVisitor: false, // is this the first time you visit + displayCount: 0, // number of times the message has been shown + optedout: false, // has the user opted out + added: false // has been actually added to the homescreen +}; + +ath.removeSession = function (appID) { + try { + if (!localStorage) { + throw new Error('localStorage is not defined'); + } + + localStorage.removeItem(appID || ath.defaults.appID); + } catch (e) { + // we are most likely in private mode + } +}; + +ath.doLog = function (logStr) { + if ( this.options.logging ) { + console.log(logStr); + } +}; + +ath.Class = function (options) { + // class methods + this.doLog = ath.doLog; + + // merge default options with user config + this.options = _extend({}, ath.defaults); + _extend(this.options, options); + // override defaults that are dependent on each other + if ( this.options && this.options.debug && (typeof this.options.logging === "undefined") ) { + this.options.logging = true; + } + + // IE<9 so exit (I hate you, really) + if ( !_eventListener ) { + return; + } + + // normalize some options + this.options.mandatory = this.options.mandatory && ( 'standalone' in window.navigator || this.options.debug ); + this.options.modal = this.options.modal || this.options.mandatory; + if ( this.options.mandatory ) { + this.options.startDelay = -0.5; // make the popup hasty + } + this.options.detectHomescreen = this.options.detectHomescreen === true ? 'hash' : this.options.detectHomescreen; + + // setup the debug environment + if ( this.options.debug ) { + ath.isCompatible = true; + ath.OS = typeof this.options.debug == 'string' ? this.options.debug : ath.OS == 'unsupported' ? 'android' : ath.OS; + ath.OSVersion = ath.OS == 'ios' ? '8' : '4'; + } + + // the element the message will be appended to + this.container = document.body; + + // load session + this.session = this.getItem(this.options.appID); + this.session = this.session ? JSON.parse(this.session) : undefined; + + // user most likely came from a direct link containing our token, we don't need it and we remove it + if ( ath.hasToken && ( !ath.isCompatible || !this.session ) ) { + ath.hasToken = false; + _removeToken(); + } + + // the device is not supported + if ( !ath.isCompatible ) { + this.doLog("Add to homescreen: not displaying callout because device not supported"); + return; + } + + this.session = this.session || _defaultSession; + + // check if we can use the local storage + try { + if (!localStorage) { + throw new Error('localStorage is not defined'); + } + + localStorage.setItem(this.options.appID, JSON.stringify(this.session)); + ath.hasLocalStorage = true; + } catch (e) { + // we are most likely in private mode + ath.hasLocalStorage = false; + + if ( this.options.onPrivate ) { + this.options.onPrivate.call(this); + } + } + + // check if this is a valid location + var isValidLocation = !this.options.validLocation.length; + for ( var i = this.options.validLocation.length; i--; ) { + if ( this.options.validLocation[i].test(document.location.href) ) { + isValidLocation = true; + break; + } + } + + // check compatibility with old versions of add to homescreen. Opt-out if an old session is found + if ( this.getItem('addToHome') ) { + this.optOut(); + } + + // critical errors: + if ( this.session.optedout ) { + this.doLog("Add to homescreen: not displaying callout because user opted out"); + return; + } + if ( this.session.added ) { + this.doLog("Add to homescreen: not displaying callout because already added to the homescreen"); + return; + } + if ( !isValidLocation ) { + this.doLog("Add to homescreen: not displaying callout because not a valid location"); + return; + } + + // check if the app is in stand alone mode + if ( ath.isStandalone ) { + // execute the onAdd event if we haven't already + if ( !this.session.added ) { + this.session.added = true; + this.updateSession(); + + if ( this.options.onAdd && ath.hasLocalStorage ) { // double check on localstorage to avoid multiple calls to the custom event + this.options.onAdd.call(this); + } + } + + this.doLog("Add to homescreen: not displaying callout because in standalone mode"); + return; + } + + // (try to) check if the page has been added to the homescreen + if ( this.options.detectHomescreen ) { + // the URL has the token, we are likely coming from the homescreen + if ( ath.hasToken ) { + _removeToken(); // we don't actually need the token anymore, we remove it to prevent redistribution + + // this is called the first time the user opens the app from the homescreen + if ( !this.session.added ) { + this.session.added = true; + this.updateSession(); + + if ( this.options.onAdd && ath.hasLocalStorage ) { // double check on localstorage to avoid multiple calls to the custom event + this.options.onAdd.call(this); + } + } + + this.doLog("Add to homescreen: not displaying callout because URL has token, so we are likely coming from homescreen"); + return; + } + + // URL doesn't have the token, so add it + if ( this.options.detectHomescreen == 'hash' ) { + history.replaceState('', window.document.title, document.location.href + '#ath'); + } else if ( this.options.detectHomescreen == 'smartURL' ) { + history.replaceState('', window.document.title, document.location.href.replace(/(\/)?$/, '/ath$1')); + } else { + history.replaceState('', window.document.title, document.location.href + (document.location.search ? '&' : '?' ) + 'ath='); + } + } + + // check if this is a returning visitor + if ( !this.session.returningVisitor ) { + this.session.returningVisitor = true; + this.updateSession(); + + // we do not show the message if this is your first visit + if ( this.options.skipFirstVisit ) { + this.doLog("Add to homescreen: not displaying callout because skipping first visit"); + return; + } + } + + // we do no show the message in private mode + if ( !this.options.privateModeOverride && !ath.hasLocalStorage ) { + this.doLog("Add to homescreen: not displaying callout because browser is in private mode"); + return; + } + + // all checks passed, ready to display + this.ready = true; + + if ( this.options.onInit ) { + this.options.onInit.call(this); + } + + if ( this.options.autostart ) { + this.doLog("Add to homescreen: autostart displaying callout"); + this.show(); + } +}; + +ath.Class.prototype = { + // event type to method conversion + events: { + load: '_delayedShow', + error: '_delayedShow', + orientationchange: 'resize', + resize: 'resize', + scroll: 'resize', + click: 'remove', + touchmove: '_preventDefault', + transitionend: '_removeElements', + webkitTransitionEnd: '_removeElements', + MSTransitionEnd: '_removeElements' + }, + + handleEvent: function (e) { + var type = this.events[e.type]; + if ( type ) { + this[type](e); + } + }, + + show: function (force) { + // in autostart mode wait for the document to be ready + if ( this.options.autostart && !_DOMReady ) { + setTimeout(this.show.bind(this), 50); + // we are not displaying callout because DOM not ready, but don't log that because + // it would log too frequently + return; + } + + // message already on screen + if ( this.shown ) { + this.doLog("Add to homescreen: not displaying callout because already shown on screen"); + return; + } + + var now = Date.now(); + var lastDisplayTime = this.session.lastDisplayTime; + + if ( force !== true ) { + // this is needed if autostart is disabled and you programmatically call the show() method + if ( !this.ready ) { + this.doLog("Add to homescreen: not displaying callout because not ready"); + return; + } + + // we obey the display pace (prevent the message to popup too often) + if ( now - lastDisplayTime < this.options.displayPace * 60000 ) { + this.doLog("Add to homescreen: not displaying callout because displayed recently"); + return; + } + + // obey the maximum number of display count + if ( this.options.maxDisplayCount && this.session.displayCount >= this.options.maxDisplayCount ) { + this.doLog("Add to homescreen: not displaying callout because displayed too many times already"); + return; + } + } + + this.shown = true; + + // increment the display count + this.session.lastDisplayTime = now; + this.session.displayCount++; + this.updateSession(); + + // try to get the highest resolution application icon + if ( !this.applicationIcon ) { + if ( ath.OS == 'ios' ) { + this.applicationIcon = document.querySelector('head link[rel^=apple-touch-icon][sizes="152x152"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon][sizes="120x120"],head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon]'); + } else { + this.applicationIcon = document.querySelector('head link[rel^="shortcut icon"][sizes="196x196"],head link[rel^=apple-touch-icon]'); + } + } + + var message = ''; + + if ( typeof this.options.message == 'object' && ath.language in this.options.message ) { // use custom language message + message = this.options.message[ath.language][ath.OS]; + } else if ( typeof this.options.message == 'object' && ath.OS in this.options.message ) { // use custom os message + message = this.options.message[ath.OS]; + } else if ( this.options.message in ath.intl ) { // you can force the locale + message = ath.intl[this.options.message][ath.OS]; + } else if ( this.options.message !== '' ) { // use a custom message + message = this.options.message; + } else if ( ath.OS in ath.intl[ath.language] ) { // otherwise we use our message + message = ath.intl[ath.language][ath.OS]; + } + + // add the action icon + message = '

    ' + message.replace(/%icon(?:\[([^\]]+)\])?/gi, function(matches, group1) { + return '' + (!!group1 ? group1 : 'icon') + ''; + }) + '

    '; + + // create the message container + this.viewport = document.createElement('div'); + this.viewport.className = 'ath-viewport'; + if ( this.options.modal ) { + this.viewport.className += ' ath-modal'; + } + if ( this.options.mandatory ) { + this.viewport.className += ' ath-mandatory'; + } + this.viewport.style.position = 'absolute'; + + // create the actual message element + this.element = document.createElement('div'); + this.element.className = 'ath-container ath-' + ath.OS + ' ath-' + ath.OS + (parseInt(ath.OSVersion) || '') + ' ath-' + (ath.isTablet ? 'tablet' : 'phone'); + this.element.style.cssText = '-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0s;-webkit-transition-timing-function:ease-out;transition-property:transform,opacity;transition-duration:0s;transition-timing-function:ease-out;'; + this.element.style.webkitTransform = 'translate3d(0,-' + window.innerHeight + 'px,0)'; + this.element.style.transform = 'translate3d(0,-' + window.innerHeight + 'px,0)'; + + // add the application icon + if ( this.options.icon && this.applicationIcon ) { + this.element.className += ' ath-icon'; + this.img = document.createElement('img'); + this.img.className = 'ath-application-icon'; + this.img.addEventListener('load', this, false); + this.img.addEventListener('error', this, false); + + this.img.src = this.applicationIcon.href; + this.element.appendChild(this.img); + } + + this.element.innerHTML += message; + + // we are not ready to show, place the message out of sight + this.viewport.style.left = '-99999em'; + + // attach all elements to the DOM + this.viewport.appendChild(this.element); + this.container.appendChild(this.viewport); + + // if we don't have to wait for an image to load, show the message right away + if ( this.img ) { + this.doLog("Add to homescreen: not displaying callout because waiting for img to load"); + } else { + this._delayedShow(); + } + }, + + _delayedShow: function (e) { + setTimeout(this._show.bind(this), this.options.startDelay * 1000 + 500); + }, + + _show: function () { + var that = this; + + // update the viewport size and orientation + this.updateViewport(); + + // reposition/resize the message on orientation change + window.addEventListener('resize', this, false); + window.addEventListener('scroll', this, false); + window.addEventListener('orientationchange', this, false); + + if ( this.options.modal ) { + // lock any other interaction + document.addEventListener('touchmove', this, true); + } + + // Enable closing after 1 second + if ( !this.options.mandatory ) { + setTimeout(function () { + that.element.addEventListener('click', that, true); + }, 1000); + } + + // kick the animation + setTimeout(function () { + that.element.style.webkitTransitionDuration = '1.2s'; + that.element.style.transitionDuration = '1.2s'; + that.element.style.webkitTransform = 'translate3d(0,0,0)'; + that.element.style.transform = 'translate3d(0,0,0)'; + }, 0); + + // set the destroy timer + if ( this.options.lifespan ) { + this.removeTimer = setTimeout(this.remove.bind(this), this.options.lifespan * 1000); + } + + // fire the custom onShow event + if ( this.options.onShow ) { + this.options.onShow.call(this); + } + }, + + remove: function () { + clearTimeout(this.removeTimer); + + // clear up the event listeners + if ( this.img ) { + this.img.removeEventListener('load', this, false); + this.img.removeEventListener('error', this, false); + } + + window.removeEventListener('resize', this, false); + window.removeEventListener('scroll', this, false); + window.removeEventListener('orientationchange', this, false); + document.removeEventListener('touchmove', this, true); + this.element.removeEventListener('click', this, true); + + // remove the message element on transition end + this.element.addEventListener('transitionend', this, false); + this.element.addEventListener('webkitTransitionEnd', this, false); + this.element.addEventListener('MSTransitionEnd', this, false); + + // start the fade out animation + this.element.style.webkitTransitionDuration = '0.3s'; + this.element.style.opacity = '0'; + }, + + _removeElements: function () { + this.element.removeEventListener('transitionend', this, false); + this.element.removeEventListener('webkitTransitionEnd', this, false); + this.element.removeEventListener('MSTransitionEnd', this, false); + + // remove the message from the DOM + this.container.removeChild(this.viewport); + + this.shown = false; + + // fire the custom onRemove event + if ( this.options.onRemove ) { + this.options.onRemove.call(this); + } + }, + + updateViewport: function () { + if ( !this.shown ) { + return; + } + + this.viewport.style.width = window.innerWidth + 'px'; + this.viewport.style.height = window.innerHeight + 'px'; + this.viewport.style.left = window.scrollX + 'px'; + this.viewport.style.top = window.scrollY + 'px'; + + var clientWidth = document.documentElement.clientWidth; + + this.orientation = clientWidth > document.documentElement.clientHeight ? 'landscape' : 'portrait'; + + var screenWidth = ath.OS == 'ios' ? this.orientation == 'portrait' ? screen.width : screen.height : screen.width; + this.scale = screen.width > clientWidth ? 1 : screenWidth / window.innerWidth; + + this.element.style.fontSize = this.options.fontSize / this.scale + 'px'; + }, + + resize: function () { + clearTimeout(this.resizeTimer); + this.resizeTimer = setTimeout(this.updateViewport.bind(this), 100); + }, + + updateSession: function () { + if ( ath.hasLocalStorage === false ) { + return; + } + + if (localStorage) { + localStorage.setItem(this.options.appID, JSON.stringify(this.session)); + } + }, + + clearSession: function () { + this.session = _defaultSession; + this.updateSession(); + }, + + getItem: function(item) { + try { + if (!localStorage) { + throw new Error('localStorage is not defined'); + } + + return localStorage.getItem(item); + } catch(e) { + // Preventing exception for some browsers when fetching localStorage key + ath.hasLocalStorage = false; + } + }, + + optOut: function () { + this.session.optedout = true; + this.updateSession(); + }, + + optIn: function () { + this.session.optedout = false; + this.updateSession(); + }, + + clearDisplayCount: function () { + this.session.displayCount = 0; + this.updateSession(); + }, + + _preventDefault: function (e) { + e.preventDefault(); + e.stopPropagation(); + } +}; + +// utility +function _extend (target, obj) { + for ( var i in obj ) { + target[i] = obj[i]; + } + + return target; +} + +function _removeToken () { + if ( document.location.hash == '#ath' ) { + history.replaceState('', window.document.title, document.location.href.split('#')[0]); + } + + if ( _reSmartURL.test(document.location.href) ) { + history.replaceState('', window.document.title, document.location.href.replace(_reSmartURL, '$1')); + } + + if ( _reQueryString.test(document.location.search) ) { + history.replaceState('', window.document.title, document.location.href.replace(_reQueryString, '$2')); + } +} + +// expose to the world +window.addToHomescreen = ath; + +})(window, document); diff --git a/inc/js/color-picker.min.js b/inc/js/color-picker.min.js new file mode 100644 index 0000000..75b6ede --- /dev/null +++ b/inc/js/color-picker.min.js @@ -0,0 +1 @@ +(function(f,e){var a='',c='
    ',b='
    ',g='';var d={options:{defaultColor:false,change:false,clear:false,hide:true,palettes:true},_create:function(){if(f.browser.msie&&parseInt(f.browser.version,10)<8){return}var h=this;var i=h.element;f.extend(h.options,i.data());h.initialValue=i.val();i.addClass("wp-color-picker").hide().wrap(b);h.wrap=i.parent();h.toggler=f(a).insertBefore(i).css({backgroundColor:h.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current);h.pickerContainer=f(c).insertAfter(i);h.button=f(g);if(h.options.defaultColor){h.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString)}else{h.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear)}i.wrap('').after(h.button);i.iris({target:h.pickerContainer,hide:true,width:255,mode:"hsv",palettes:h.options.palettes,change:function(j,k){h.toggler.css({backgroundColor:k.color.toString()});if(f.isFunction(h.options.change)){h.options.change.call(this,j,k)}}});i.val(h.initialValue);h._addListeners();if(!h.options.hide){h.toggler.click()}},_addListeners:function(){var h=this;h.toggler.click(function(i){i.stopPropagation();h.element.toggle().iris("toggle");h.button.toggleClass("hidden");h.toggler.toggleClass("wp-picker-open");if(h.toggler.hasClass("wp-picker-open")){f("body").on("click",{wrap:h.wrap,toggler:h.toggler},h._bodyListener)}else{f("body").off("click",h._bodyListener)}});h.element.change(function(j){var i=f(this),k=i.val();if(k===""||k==="#"){h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}});h.toggler.on("keyup",function(i){if(i.keyCode===13||i.keyCode===32){i.preventDefault();h.toggler.trigger("click").next().focus()}});h.button.click(function(j){var i=f(this);if(i.hasClass("wp-picker-clear")){h.element.val("");h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}else{if(i.hasClass("wp-picker-default")){h.element.val(h.options.defaultColor).change()}}})},_bodyListener:function(h){if(!h.data.wrap.find(h.target).length){h.data.toggler.click()}},color:function(h){if(h===e){return this.element.iris("option","color")}this.element.iris("option","color",h)},defaultColor:function(h){if(h===e){return this.options.defaultColor}this.options.defaultColor=h}};f.widget("wp.wpColorPicker",d)}(jQuery)); \ No newline at end of file diff --git a/inc/js/iris.min.js b/inc/js/iris.min.js new file mode 100644 index 0000000..105195d --- /dev/null +++ b/inc/js/iris.min.js @@ -0,0 +1,4 @@ +/*! Iris - v0.9.14 - 2012-11-20 +* https://github.com/Automattic/Iris +* Copyright (c) 2012 Matt Wiebe; Licensed GPL */ +(function(e,t){function u(){if(r)i="filter";else{var t=e('
    '),n="linear-gradient(top,#fff,#000)";e.each(s,function(e,r){t.css("backgroundImage",r+n);if(t.css("backgroundImage").match("gradient"))return i=e,!1}),e.browser.webkit&&i===!1&&(t.css("background","-webkit-gradient(linear,0% 0%,0% 100%,from(#fff),to(#000))"),t.css("backgroundImage").match("gradient")&&(i="webkit")),t.remove()}}function a(t,n){return t=t==="top"?"top":"left",n=e.isArray(n)?n:Array.prototype.slice.call(arguments,1),i==="webkit"?l(t,n):s[i]+"linear-gradient("+t+", "+n.join(", ")+")"}function f(t,n){t=t==="top"?"top":"left",n=e.isArray(n)?n:Array.prototype.slice.call(arguments,1);var r=t==="top"?0:1,i=e(this),s=n.length-1,o=parseInt(e.browser.version,10)>=8?"-ms-filter":"filter";o="filter";var u=r===1?"left":"top",a=r===1?"right":"bottom",f=r===1?"height":"width",l='
    ',h="";i.css("position")==="static"&&i.css({position:"relative"}),n=c(n),e.each(n,function(e,t){if(e===s)return!1;var i=n[e+1];if(t.stop===i.stop)return;var o=100-parseFloat(i.stop)+"%";t.octoHex=(new Color(t.color)).toIEOctoHex(),i.octoHex=(new Color(i.color)).toIEOctoHex();var u="progid:DXImageTransform.Microsoft.Gradient(GradientType="+r+", StartColorStr='"+t.octoHex+"', EndColorStr='"+i.octoHex+"')";h+=l.replace("%start%",t.stop).replace("%end%",o).replace("%filter%",u)}),i.find(".iris-ie-gradient-shim").remove(),e(h).prependTo(i)}function l(t,n){var r=[];return t=t==="top"?"0% 0%,0% 100%,":"0% 100%,100% 100%,",n=c(n),e.each(n,function(e,t){r.push("color-stop("+parseFloat(t.stop)/100+", "+t.color+")")}),"-webkit-gradient(linear,"+t+r.join(",")+")"}function c(t){var n=[],r=[],i=[],s=t.length-1;return e.each(t,function(e,t){var i=t,s=!1,o=t.match(/1?[0-9]{1,2}%$/);o&&(i=t.replace(/\s?1?[0-9]{1,2}%$/,""),s=o.shift()),n.push(i),r.push(s)}),r[0]===!1&&(r[0]="0%"),r[s]===!1&&(r[s]="100%"),r=h(r),e.each(r,function(e){i[e]={color:n[e],stop:r[e]}}),i}function h(t){var n=0,r=t.length-1,i=0,s=!1,o,u,a,f;if(t.length<=2||e.inArray(!1,t)<0)return t;while(i"),n=e("
    "),r=e.isArray(this.options.palettes)?this.options.palettes:this._palettes;e.each(r,function(e,r){n.clone().data("color",r).css("backgroundColor",r).appendTo(t).height(10).width(10)}),this.picker.append(t)},_paint:function(){var e=this;e._paintDimension("top","strip"),e._paintDimension("top","vert"),e._paintDimension("left","horiz")},_paintDimension:function(e,t){var n=this,r=n.color,i=n.options.mode,s=n._getHSpaceColor(),o=n.controls[t],u=n.options.controls,a;if(t===n.active||n.active==="square"&&t!=="strip")return;switch(u[t]){case"h":if(i==="hsv"){s=r.clone();switch(t){case"horiz":s[u.vert](100);break;case"vert":s[u.horiz](100);break;case"strip":s.setHSpace("hsl")}a=s.toHsl()}else t==="strip"?a={s:s.s,l:s.l}:a={s:100,l:s.l};o.raninbowGradient(e,a);break;case"s":i==="hsv"?t==="vert"?a=[r.clone().a(0).s(0).toCSS("rgba"),r.clone().a(1).s(0).toCSS("rgba")]:t==="strip"?a=[r.clone().s(100).toCSS("hsl"),r.clone().s(0).toCSS("hsl")]:t==="horiz"&&(a=["#fff","hsl("+s.h+",100%,50%)"]):t==="vert"&&n.options.controls.horiz==="h"?a=["hsla(0, 0%, "+s.l+"%, 0)","hsla(0, 0%, "+s.l+"%, 1)"]:a=["hsl("+s.h+",0%,50%)","hsl("+s.h+",100%,50%)"],o.gradient(e,a);break;case"l":t==="strip"?a=["hsl("+s.h+",100%,100%)","hsl("+s.h+", "+s.s+"%,50%)","hsl("+s.h+",100%,0%)"]:a=["#fff","rgba(255,255,255,0) 50%","rgba(0,0,0,0) 50%","rgba(0,0,0,1)"],o.gradient(e,a);break;case"v":t==="strip"?a=[r.clone().v(100).toCSS(),r.clone().v(0).toCSS()]:a=["rgba(0,0,0,0)","#000"],o.gradient(e,a);break;default:}},_getHSpaceColor:function(){return this.options.mode==="hsv"?this.color.toHsv():this.color.toHsl()},_dimensions:function(t){var n=this,r=n.options,i=n.picker.find(".iris-picker-inner"),s=n.controls,o=s.square,u=n.picker.find(".iris-strip"),a="77.5%",f="12%",l=20,c=r.border?r.width-l:r.width,h,p=e.isArray(r.palettes)?r.palettes.length:n._palettes.length,d,v,m;t&&(o.css("width",""),u.css("width",""),n.picker.removeAttr("style")),a=c*(parseFloat(a)/100),f=c*(parseFloat(f)/100),h=r.border?a+l:a,o.width(a).height(a),u.height(a).width(f),n.picker.css({width:r.width,height:h});if(!r.palettes)return;d=a*2/100,m=a-(p-1)*d,v=m/p,n.picker.find(".iris-palette").each(function(t,n){var r=t===0?0:d;e(this).css({width:v,height:v,marginLeft:r})}),n.picker.css("paddingBottom",v+d),u.height(v+d+a)},_addInputListeners:function(e){var t=this,n=100,r=function(n){var r=new Color(e.val()),i=e.val().replace(/^#/,"");e.removeClass("iris-error"),r.error?i!==""&&e.addClass("iris-error"):r.toString()!==t.color.toString()&&(n.type!=="keyup"||!i.match(/^[0-9a-fA-F]{3}$/))&&t._setOption("color",r.toString())};e.on("change",r).on("keyup",t._debounce(r,n))},_initControls:function(){var t=this,n=t.controls,r=n.square,i=t.options.controls,s=t._scale[i.strip];n.stripSlider.slider({orientation:"vertical",max:s,slide:function(e,n){t.active="strip",i.strip==="h"&&(n.value=s-n.value),t.color[i.strip](n.value),t._change.apply(t,arguments)}}),n.squareDrag.draggable({containment:"parent",zIndex:1e3,cursor:"move",drag:function(e,n){t._squareDrag(e,n)},start:function(){r.addClass("iris-dragging"),e(this).addClass("ui-state-focus")},stop:function(){r.removeClass("iris-dragging"),e(this).removeClass("ui-state-focus")}}).on("mousedown mouseup",function(n){n.preventDefault();var r="ui-state-focus";n.type==="mousedown"?(t.picker.find("."+r).removeClass(r).blur(),e(this).addClass(r).focus()):e(this).removeClass(r)}).on("keydown",function(e){var r=n.square,i=n.squareDrag,s=i.position(),o=t.options.width/100;e.altKey&&(o*=10);switch(e.keyCode){case 37:s.left-=o;break;case 38:s.top-=o;break;case 39:s.left+=o;break;case 40:s.top+=o;break;default:return!0}s.left=Math.max(0,Math.min(s.left,r.width())),s.top=Math.max(0,Math.min(s.top,r.height())),i.css(s),t._squareDrag(e,{position:s}),e.preventDefault()}),r.mousedown(function(n){if(n.which!==1)return;if(!e(n.target).is("div"))return;var r=t.controls.square.offset(),i={top:n.pageY-r.top,left:n.pageX-r.left};n.preventDefault(),t._squareDrag(n,{position:i}),n.target=t.controls.squareDrag.get(0),t.controls.squareDrag.css(i).trigger(n)}),t.options.palettes&&t.picker.find(".iris-palette-container").on("click",".iris-palette",function(n){t.color.fromCSS(e(this).data("color")),t.active="external",t._change()}).on("keydown",".iris-palette",function(t){if(t.keyCode!==13&&t.keyCode!==32)return!0;t.stopPropagation(),e(this).click()})},_squareDrag:function(e,t){var n=this,r=n.options.controls,i=n._squareDimensions(),s=Math.round((i.h-t.position.top)/i.h*n._scale[r.vert]),o=n._scale[r.horiz]-Math.round((i.w-t.position.left)/i.w*n._scale[r.horiz]);n.color[r.horiz](o)[r.vert](s),n.active="square",n._change.apply(n,arguments)},_setOption:function(e,t){var n=this.options[e];if(e==="color"){t=""+t;var r=t.replace(/^#/,""),i=(new Color(t)).setHSpace(this.options.mode);i.error||(this.color=i,this.options.color=this.options[e]=this.color.toString(),this.active="external",this._change())}},_squareDimensions:function(e){var n=this.controls.square,r,i;return e!==t&&n.data("dimensions")?n.data("dimensions"):(i=this.controls.squareDrag,r={w:n.width(),h:n.height()},n.data("dimensions",r),r)},_isNonHueControl:function(e,t){return e==="square"&&this.options.controls.strip==="h"?!0:t==="external"||t==="h"&&e==="strip"?!1:!0},_change:function(t,n){var r=this,i=r.controls,s=r._getHSpaceColor(),o=r.color.toString(),u=["square","strip"],a=r.options.controls,f=a[r.active]||"external",l=r.hue;r.active==="strip"?u=[]:r.active!=="external"&&u.pop(),e.each(u,function(e,t){var n;if(t!==r.active)switch(t){case"strip":n=a.strip==="h"?r._scale[a.strip]-s[a.strip]:s[a.strip],i.stripSlider.slider("value",n);break;case"square":var o=r._squareDimensions(),u={left:s[a.horiz]/r._scale[a.horiz]*o.w,top:o.h-s[a.vert]/r._scale[a.vert]*o.h};r.controls.squareDrag.css(u)}}),s.h!==l&&r._isNonHueControl(r.active,f)&&r.color.h(l),r.hue=r.color.h(),r.options.color=r.color.toString(),r._inited&&r._trigger("change",{type:r.active},{color:r.color}),r.element.is(":input")&&!r.color.error&&(r.element.removeClass("iris-error"),r.element.val()!==r.color.toString()&&r.element.val(r.color.toString())),r._paint(),r._inited=!0,r.active=!1},_debounce:function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},show:function(){this.picker.show()},hide:function(){this.picker.hide()},toggle:function(){this.picker.toggle()}};e.widget("a8c.iris",p),e('").appendTo("head")})(jQuery),function(e,t){var n=function(e,t){return this instanceof n?this._init(e,t):new n(e,t)};n.fn=n.prototype={_color:0,_alpha:1,error:!1,_hsl:{h:0,s:0,l:0},_hsv:{h:0,s:0,v:0},_hSpace:"hsl",_init:function(e){var n="noop";switch(typeof e){case"object":return e.a!==t&&this.a(e.a),n=e.r!==t?"fromRgb":e.l!==t?"fromHsl":e.v!==t?"fromHsv":n,this[n](e);case"string":return this.fromCSS(e);case"number":return this.fromInt(parseInt(e,10))}return this},_error:function(){return this.error=!0,this},clone:function(){var e=new n(this.toInt()),t=["_alpha","_hSpace","_hsl","_hsv","error"];for(var r=t.length-1;r>=0;r--)e[t[r]]=this[t[r]];return e},setHSpace:function(e){return this._hSpace=e==="hsv"?e:"hsl",this},noop:function(){return this},fromCSS:function(e){var t,n,r=/^(rgb|hs(l|v))a?\(/;this.error=!1,e=e.replace(/^\s+/,"").replace(/\s+$/,"").replace(/;$/,"");if(e.match(r)&&e.match(/\)$/)){n=e.replace(/(\s|%)/g,"").replace(r,"").replace(/,?\);?$/,"").split(",");if(n.length<3)return this._error();if(n.length===4){this.a(parseFloat(n.pop()));if(this.error)return this}for(var i=n.length-1;i>=0;i--){n[i]=parseInt(n[i],10);if(isNaN(n[i]))return this._error()}return e.match(/^rgb/)?this.fromRgb({r:n[0],g:n[1],b:n[2]}):e.match(/^hsv/)?this.fromHsv({h:n[0],s:n[1],v:n[2]}):this.fromHsl({h:n[0],s:n[1],l:n[2]})}return this.fromHex(e)},fromRgb:function(e,n){return typeof e!="object"||e.r===t||e.g===t||e.b===t?this._error():(this.error=!1,this.fromInt(parseInt((e.r<<16)+(e.g<<8)+e.b,10),n))},fromHex:function(e){return e=e.replace(/^#/,"").replace(/^0x/,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),this.error=!/^[0-9A-F]{6}$/i.test(e),this.fromInt(parseInt(e,16))},fromHsl:function(e){var n,r,i,s,o,u,a,f;return typeof e!="object"||e.h===t||e.s===t||e.l===t?this._error():(this._hsl=e,this._hSpace="hsl",u=e.h/360,a=e.s/100,f=e.l/100,a===0?n=r=i=f:(s=f<.5?f*(1+a):f+a-f*a,o=2*f-s,n=this.hue2rgb(o,s,u+1/3),r=this.hue2rgb(o,s,u),i=this.hue2rgb(o,s,u-1/3)),this.fromRgb({r:n*255,g:r*255,b:i*255},!0))},fromHsv:function(e){var n,r,i,s,o,u,a,f,l,c,h;if(typeof e!="object"||e.h===t||e.s===t||e.v===t)return this._error();this._hsv=e,this._hSpace="hsv",n=e.h/360,r=e.s/100,i=e.v/100,a=Math.floor(n*6),f=n*6-a,l=i*(1-r),c=i*(1-f*r),h=i*(1-(1-f)*r);switch(a%6){case 0:s=i,o=h,u=l;break;case 1:s=c,o=i,u=l;break;case 2:s=l,o=i,u=h;break;case 3:s=l,o=c,u=i;break;case 4:s=h,o=l,u=i;break;case 5:s=i,o=l,u=c}return this.fromRgb({r:s*255,g:o*255,b:u*255},!0)},fromInt:function(e,n){return this._color=parseInt(e,10),isNaN(this._color)&&(this._color=0),this._color>16777215?this._color=16777215:this._color<0&&(this._color=0),n===t&&(this._hsv.h=this._hsv.s=this._hsl.h=this._hsl.s=0),this},hue2rgb:function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e},toString:function(){var e=parseInt(this._color,10).toString(16);if(this.error)return"";if(e.length<6)for(var t=6-e.length-1;t>=0;t--)e="0"+e;return"#"+e},toCSS:function(e,t){e=e||"hex",t=parseFloat(t||this._alpha);switch(e){case"rgb":case"rgba":var n=this.toRgb();return t<1?"rgba( "+n.r+", "+n.g+", "+n.b+", "+t+" )":"rgb( "+n.r+", "+n.g+", "+n.b+" )";case"hsl":case"hsla":var r=this.toHsl();return t<1?"hsla( "+r.h+", "+r.s+"%, "+r.l+"%, "+t+" )":"hsl( "+r.h+", "+r.s+"%, "+r.l+"% )";default:return this.toString()}},toRgb:function(){return{r:255&this._color>>16,g:255&this._color>>8,b:255&this._color}},toHsl:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),s=Math.min(t,n,r),o,u,a=(i+s)/2;if(i===s)o=u=0;else{var f=i-s;u=a>.5?f/(2-i-s):f/(i+s);switch(i){case t:o=(n-r)/f+(nr?(t+.05)/(r+.05):(r+.05)/(t+.05)}throw"getDistanceLuminosityFrom requires a Color object"},getMaxContrastColor:function(){var e=this.toLuminosity(),t=e>=.5?"000000":"ffffff";return new n(t)},getGrayscaleContrastingColor:function(e){if(!e)return this.getMaxContrastColor();var t=e<5?5:e,n=this.getMaxContrastColor();e=n.getDistanceLuminosityFrom(this);if(e<=t)return n;var r=0===n.toInt()?1:-1;while(e>t)n=n.incrementLightness(r),e=n.getDistanceLuminosityFrom(this);return n},getReadableContrastingColor:function(e,r){if(!e instanceof n)return this;var i=r===t?5:r,s=e.getDistanceLuminosityFrom(this),o=e.getMaxContrastColor(),u=o.getDistanceLuminosityFrom(e);if(u<=i)return o;if(s>=i)return this;var a=0===o.toInt()?-1:1;while(sn.range[1]?n.range[1]:r),s[e]=r,this._spaceFunc("from",n.space,s))}},_spaceFunc:function(e,t,n){var r=t||this._hSpace,i=e+r.charAt(0).toUpperCase()+r.substr(1);return this[i](n)}};var r={h:{mod:360},s:{range:[0,100]},l:{space:"hsl",range:[0,100]},v:{space:"hsv",range:[0,100]},r:{space:"rgb",range:[0,255]},g:{space:"rgb",range:[0,255]},b:{space:"rgb",range:[0,255]}};for(var i in r)r.hasOwnProperty(i)&&(n.fn[i]=n.fn._partial(i));e.Color=n}(typeof exports=="object"&&exports||this); \ No newline at end of file diff --git a/inc/js/media-uploader.js b/inc/js/media-uploader.js new file mode 100644 index 0000000..3112d27 --- /dev/null +++ b/inc/js/media-uploader.js @@ -0,0 +1,79 @@ +jQuery(document).ready(function($){ + + var optionsframework_upload; + var optionsframework_selector; + + function optionsframework_add_file(event, selector) { + + var upload = $(".uploaded-file"), frame; + var $el = $(this); + optionsframework_selector = selector; + + event.preventDefault(); + + // If the media frame already exists, reopen it. + if ( optionsframework_upload ) { + optionsframework_upload.open(); + } else { + // Create the media frame. + optionsframework_upload = wp.media.frames.optionsframework_upload = wp.media({ + // Set the title of the modal. + title: $el.data('choose'), + + // Customize the submit button. + button: { + // Set the text of the button. + text: $el.data('update'), + // Tell the button not to close the modal, since we're + // going to refresh the page when the image is selected. + close: false + } + }); + + // When an image is selected, run a callback. + optionsframework_upload.on( 'select', function() { + // Grab the selected attachment. + var attachment = optionsframework_upload.state().get('selection').first(); + optionsframework_upload.close(); + optionsframework_selector.find('.upload').val(attachment.attributes.url); + if ( attachment.attributes.type == 'image' ) { + optionsframework_selector.find('.screenshot').empty().hide().append('Remove').slideDown('fast'); + } + optionsframework_selector.find('.upload-button').unbind().addClass('remove-file').removeClass('upload-button').val(optionsframework_l10n.remove); + optionsframework_selector.find('.of-background-properties').slideDown(); + optionsframework_selector.find('.remove-image, .remove-file').on('click', function() { + optionsframework_remove_file( $(this).parents('.section') ); + }); + }); + + } + + // Finally, open the modal. + optionsframework_upload.open(); + } + + function optionsframework_remove_file(selector) { + selector.find('.remove-image').hide(); + selector.find('.upload').val(''); + selector.find('.of-background-properties').hide(); + selector.find('.screenshot').slideUp(); + selector.find('.remove-file').unbind().addClass('upload-button').removeClass('remove-file').val(optionsframework_l10n.upload); + // We don't display the upload button if .upload-notice is present + // This means the user doesn't have the WordPress 3.5 Media Library Support + if ( $('.section-upload .upload-notice').length > 0 ) { + $('.upload-button').remove(); + } + selector.find('.upload-button').on('click', function(event) { + optionsframework_add_file(event, $(this).parents('.section')); + }); + } + + $('.remove-image, .remove-file').on('click', function() { + optionsframework_remove_file( $(this).parents('.section') ); + }); + + $('.upload-button').click( function( event ) { + optionsframework_add_file(event, $(this).parents('.section')); + }); + +}); \ No newline at end of file diff --git a/inc/js/options-custom.js b/inc/js/options-custom.js new file mode 100644 index 0000000..522c601 --- /dev/null +++ b/inc/js/options-custom.js @@ -0,0 +1,91 @@ +/** + * Prints out the inline javascript needed for the colorpicker and choosing + * the tabs in the panel. + */ + +jQuery(document).ready(function($) { + + // Fade out the save message + $('.fade').delay(1000).fadeOut(1000); + + $('.of-color').wpColorPicker(); + + // Switches option sections + $('.group').hide(); + var active_tab = ''; + if (typeof(localStorage) != 'undefined' ) { + active_tab = localStorage.getItem("active_tab"); + } + if (active_tab != '' && $(active_tab).length ) { + $(active_tab).fadeIn(); + } else { + $('.group:first').fadeIn(); + } + $('.group .collapsed').each(function(){ + $(this).find('input:checked').parent().parent().parent().nextAll().each( + function(){ + if ($(this).hasClass('last')) { + $(this).removeClass('hidden'); + return false; + } + $(this).filter('.hidden').removeClass('hidden'); + }); + }); + if (active_tab != '' && $(active_tab + '-tab').length ) { + $(active_tab + '-tab').addClass('nav-tab-active'); + } + else { + $('.nav-tab-wrapper a:first').addClass('nav-tab-active'); + } + + $('.nav-tab-wrapper a').click(function(evt) { + $('.nav-tab-wrapper a').removeClass('nav-tab-active'); + $(this).addClass('nav-tab-active').blur(); + var clicked_group = $(this).attr('href'); + if (typeof(localStorage) != 'undefined' ) { + localStorage.setItem("active_tab", $(this).attr('href')); + } + $('.group').hide(); + $(clicked_group).fadeIn(); + evt.preventDefault(); + + // Editor Height (needs improvement) + $('.wp-editor-wrap').each(function() { + var editor_iframe = $(this).find('iframe'); + if ( editor_iframe.height() < 30 ) { + editor_iframe.css({'height':'auto'}); + } + }); + + }); + + $('.group .collapsed input:checkbox').click(unhideHidden); + + function unhideHidden(){ + if ($(this).attr('checked')) { + $(this).parent().parent().parent().nextAll().removeClass('hidden'); + } + else { + $(this).parent().parent().parent().nextAll().each( + function(){ + if ($(this).filter('.last').length) { + $(this).addClass('hidden'); + return false; + } + $(this).addClass('hidden'); + }); + + } + } + + // Image Options + $('.of-radio-img-img').click(function(){ + $(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected'); + $(this).addClass('of-radio-img-selected'); + }); + + $('.of-radio-img-label').hide(); + $('.of-radio-img-img').show(); + $('.of-radio-img-radio').hide(); + +}); \ No newline at end of file diff --git a/inc/login.css b/inc/login.css new file mode 100644 index 0000000..05140c1 --- /dev/null +++ b/inc/login.css @@ -0,0 +1,366 @@ +/* clear float */ +.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.clearfix { display: block; } + +/* common */ +html { overflow:hidden; background-color: #000;} +body { background:none !important; overflow:hidden;} + +#bg{ + -webkit-filter: blur(2px); /* Chrome, Opera */ + -moz-filter: blur(2px); + -ms-filter: blur(2px); + filter: blur(2px); +} +#bg img { opacity: 1 !important;; } + +.login #login_error, .login .message { + /*position: absolute; + top: -70px;*/ + left: 0; + top: 0; + position: fixed; + margin-bottom: 0 !important; + background: rgba(255, 255, 255, 0.45); +} + +/* login */ +#login { + font:14px/1.4 "Helvetica Neue","HelveticaNeue",Helvetica,Arial,sans-serif; + position:absolute; + background: rgba(255, 255, 255, 0.45); + border-radius: 6px; + top:50%; + left:50%; + width:350px; + padding:0px !important; + margin:-235px 0px 0px -175px !important; + background-position: center 48%; +} + +#login h1 a { + font-family:"Microsoft Yahei"; + font-weight:bold; + text-indent:0px; + font-size:0px; + height:32px; + width: 100%; + line-height:88px; + line-height:180%; + text-align:center; color:#FFF; + /*text-shadow:1px 1px 0px #000;*/ + margin-bottom:10px; + margin-top: 25px; + background-image:url(../images/mashiro-logo-s.png); + background-position: center bottom !important; + background-size: contain; + padding-top: 20px; + box-shadow: none; +} + +input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 1000px rgba(0, 0, 0, 0) inset;; +color: #676767 !important} + +#login form { + padding:10px 0px; + background: none; + box-shadow: none; + margin-top: 10px; +} + +#login form p { + font-family:"Microsoft Yahei"; + position:relative; + padding:0px 35px; +} + +#login a { + /*text-shadow:1px 1px 0px #000;*/ + color:#000 !important; + font-family:"Microsoft Yahei"; +} +#login_error a { + color:#000 !important; + /*text-shadow:1px 1px 0px #FFF;*/ +} + +#login form label { + color:#333; + color: #585858; +} + +#login form .input { + border:1px solid #EAEAEA; + border-radius:0px; + background:none; + padding:5px 10px; + color:#444; + font-weight:normal; + font-size:14px; + background:#FFF; + font-family:"Microsoft Yahei"; + box-shadow: 0 0 0px 1000px white inset; + height: 46px; + border-radius: 3px; + margin-top: 10px; +} + +#login form .input:active { + box-shadow:0 0 0px 1000px white inset; + color: #676767 !important; +} + +#login form .input:focus { + box-shadow:0 0 0px 1000px white inset; + color: #676767 !important; + border: 1px solid #FF5656; +} + +#login .form-send .bot { + width:100%; + border-bottom:1px solid #ccc; +} + +#login form .forgetmenot { + float:none; +} + +#login form p.submit { + padding:0px 35px !important; +} + +#login .submit .button { + width:100%; + margin: 10px auto; + border:none; + float:none; + border-radius:30px; + height:50px; + font-size:14px; + text-align:center; + color:#FFF; + background:#FF5656; + font-weight:normal; + cursor:pointer; + box-shadow: none; + text-shadow: none; + letter-spacing:2px +} + +.login #nav , #backtoblog { + /*display:none*/ + color: #585858 !important; +} + +.login #backtoblog { + display:none +} + +.login #nav { + margin: 0; + margin-bottom: 0; + text-align: center; +} + +.login .ds-login{ + margin-left: 38px; +} + +.login form input[type=checkbox] { + background: #FFFFFF; + box-shadow: none; + width:20px; + height:20px; + border-radius: 2px; +} + +input[type=checkbox]:checked:before { + content: "\f147"; + margin: -2px 0 0 -2px; + color: #FF5656; +} + +/* loading */ +.loading { position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:99; overflow:hidden; background:#000; } +.loading img { position:absolute; top:50%; left:50%; width:58px; height:10px; margin:-5px 0px 0px -29px; } + +/* auto hide */ +.login #login_error { + position: absolute; + border-radius: 6px; + width: 322px +} +.login .message { + border-radius: 6px; + -moz-animation: cssAnimation 0s ease-in 5s forwards; + /* Firefox */ + -webkit-animation: cssAnimation 0s ease-in 5s forwards; + /* Safari and Chrome */ + -o-animation: cssAnimation 0s ease-in 5s forwards; + /* Opera */ + animation: cssAnimation 0s ease-in 5s forwards; + -webkit-animation-fill-mode: forwards; + animation-fill-mode: forwards; +} +@keyframes cssAnimation { + to { + padding: 0; + width:0; + height:0; + overflow:hidden; + } +} +@-webkit-keyframes cssAnimation { + to { + padding: 0; + width:0; + height:0; + visibility:hidden; + } +} + +/*reset password page*/ +.password-input-wrapper { + width: 100%; + margin-top: 10px; +} + +.password-input { + margin-top: 0 !important; +} + +.button-secondary { + padding-top: 10px !important; + padding-left: 40px !important; +} + +/*֤*/ +#slider { + margin: 0 auto; + /*width: 300px;*/ + height: 46px; + position: relative; + border-radius: 3px; + background-color: #eee; + overflow: hidden; + text-align: center; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; +} + +#slider_bg { + position: absolute; + left: 0; + top: 0; + height: 100%; + /*background-color: #444;*/ + z-index: 1; + border-radius: 3px 0 0 3px; + background: #FF5656; /* fallback for old browsers */ + background: -webkit-linear-gradient(to left, #FFC371, #FF5656); /* Chrome 10-25, Safari 5.1-6 */ + background: linear-gradient(to left, #FFC371, #FF5656); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ +} + +#label { + width: 46px; + position: absolute; + left: 0; + top: 0; + height: 46px; + line-height: 38px; + border: 1px solid #ddd; + background: #fff; + z-index: 3; + cursor: move; + color: #E67474; + font-size: 38px; + font-weight: 900; + border-radius: 3px; +} + +#labelTip { + position: absolute; + left: 0; + width: 100%; + height: 100%; + font-size: 13px; + font-family: 'Microsoft Yahei', serif; + color: #888; + line-height: 46px; + text-align: center; + z-index: 2; +} +#verification-slider{ + margin: 1em; + padding: 0px 21px; +} +#verification-ok{ + color: #777 !important; + margin: auto; + margin-top: 0 !important; + text-align: center; +} + +.clear { + display:none +} + +.login form .forgetmenot label { + font-size: 14px !important; +} + +#rememberme { + float: right; + margin-top: 0px; +} + +.forgetmenot input[type=checkbox] { + height: 0; + width: 0; + visibility: hidden; +} + +.forgetmenot label { + cursor: pointer; + text-indent: -999.9px; + width: 21.0px; + height: 11.0px; + background: grey; + display: block; + border-radius: 10.0px; + position: relative; +} + +.forgetmenot label:after { + content: ''; + position: absolute; + top: 1px; + left: 1px; + width: 9.0px; + height: 9.0px; + background: #fff; + border-radius: 9.0px; + transition: 0.3s; +} + +.forgetmenot input:checked + label { + background: #bada55; +} + +.forgetmenot input:checked + label:after { + left: calc(100% - 1px); + transform: translateX(-100%); +} + +.forgetmenot label:active:after { + width: 13.0px; +} + +.pw-weak { + text-align: center +} + +.login .privacy-policy-page-link { + margin: 1em 0 1em !important; +} diff --git a/inc/options-framework.php b/inc/options-framework.php new file mode 100644 index 0000000..87e44d8 --- /dev/null +++ b/inc/options-framework.php @@ -0,0 +1,495 @@ + __( 'Sakura Options', 'optionsframework'), + 'menu_title' => __('Sakura Options', 'optionsframework'), + 'capability' => 'edit_theme_options', + 'menu_slug' => 'options-framework', + 'callback' => 'optionsframework_page' + ); + + return apply_filters( 'optionsframework_menu', $menu ); +} + +/* Add a subpage called "Theme Options" to the appearance menu. */ + +function optionsframework_add_page() { + + $menu = optionsframework_menu_settings(); + $of_page = add_theme_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['menu_slug'], $menu['callback'] ); + + // Load the required CSS and javscript + add_action( 'admin_enqueue_scripts', 'optionsframework_load_scripts' ); + add_action( 'admin_print_styles-' . $of_page, 'optionsframework_load_styles' ); +} + +/* Loads the CSS */ + +function optionsframework_load_styles() { + wp_enqueue_style( 'optionsframework', OPTIONS_FRAMEWORK_DIRECTORY.'css/optionsframework.css' ); + if ( !wp_style_is( 'wp-color-picker','registered' ) ) { + wp_register_style( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY.'css/color-picker.min.css' ); + } + wp_enqueue_style( 'wp-color-picker' ); +} + +/* Loads the javascript */ + +function optionsframework_load_scripts( $hook ) { + + $menu = optionsframework_menu_settings(); + + if ( 'appearance_page_' . $menu['menu_slug'] != $hook ) + return; + + // Enqueue colorpicker scripts for versions below 3.5 for compatibility + if ( !wp_script_is( 'wp-color-picker', 'registered' ) ) { + wp_register_script( 'iris', OPTIONS_FRAMEWORK_DIRECTORY . 'js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); + wp_register_script( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY . 'js/color-picker.min.js', array( 'jquery', 'iris' ) ); + $colorpicker_l10n = array( + 'clear' => __( 'Clear','options_framework_theme' ), + 'defaultString' => __( 'Default', 'options_framework_theme' ), + 'pick' => __( 'Select Color', 'options_framework_theme' ) + ); + wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n ); + } + + // Enqueue custom option panel JS + wp_enqueue_script( 'options-custom', OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ) ); + + // Inline scripts from options-interface.php + add_action( 'admin_head', 'of_admin_head' ); +} + +function of_admin_head() { + // Hook to add custom scripts + do_action( 'optionsframework_custom_scripts' ); +} + +/* + * Builds out the options panel. + * + * If we were using the Settings API as it was likely intended we would use + * do_settings_sections here. But as we don't want the settings wrapped in a table, + * we'll call our own custom optionsframework_fields. See options-interface.php + * for specifics on how each individual field is generated. + * + * Nonces are provided using the settings_fields() + * + */ + +if ( !function_exists( 'optionsframework_page' ) ) : +function optionsframework_page() { ?> + +
    + + + + + +
    +
    +
    + + +
    + + +
    +
    +
    +
    +
    + +
    + + $value ) { + $input[$id][$key] = false; + } + } + + // For a value to be submitted to database it must pass through a sanitization filter + if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { + $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option ); + } + } + + // Hook to run after validation + do_action( 'optionsframework_after_validate', $clean ); + + return $clean; +} + +/** + * Display message when options have been saved + */ + +function optionsframework_save_options_notice() { + add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'options_framework_theme' ), 'updated fade' ); +} + +add_action( 'optionsframework_after_validate', 'optionsframework_save_options_notice' ); + +/** + * Format Configuration Array. + * + * Get an array of all default values as set in + * options.php. The 'id','std' and 'type' keys need + * to be defined in the configuration array. In the + * event that these keys are not present the option + * will not be included in this function's output. + * + * @return array Rey-keyed options configuration array. + * + * @access private + */ + +function of_get_default_values() { + $output = array(); + $config =& _optionsframework_options(); + foreach ( (array) $config as $option ) { + if ( ! isset( $option['id'] ) ) { + continue; + } + if ( ! isset( $option['std'] ) ) { + continue; + } + if ( ! isset( $option['type'] ) ) { + continue; + } + if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { + $output[$option['id']] = apply_filters( 'of_sanitize_' . $option['type'], $option['std'], $option ); + } + } + return $output; +} + +/** + * Add Theme Options menu item to Admin Bar. + */ + +function optionsframework_adminbar() { + + global $wp_admin_bar; + + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'of_theme_options', + 'title' => __( 'Sakura Options', 'options_framework_theme' ), + 'href' => admin_url( 'themes.php?page=options-framework' ) + )); +} + +/** + * Wrapper for optionsframework_options() + * + * Allows for manipulating or setting options via 'of_options' filter + * For example: + * + * + * add_filter('of_options', function($options) { + * $options[] = array( + * 'name' => 'Input Text Mini', + * 'desc' => 'A mini text input field.', + * 'id' => 'example_text_mini', + * 'std' => 'Default', + * 'class' => 'mini', + * 'type' => 'text' + * ); + * + * return $options; + * }); + * + * + * Also allows for setting options via a return statement in the + * options.php file. For example (in options.php): + * + * + * return array(...); + * + * + * @return array (by reference) + */ +function &_optionsframework_options() { + static $options = null; + + if ( !$options ) { + // Load options from options.php file (if it exists) + $location = apply_filters( 'options_framework_location', array('options.php') ); + if ( $optionsfile = locate_template( $location ) ) { + $maybe_options = require_once $optionsfile; + if ( is_array($maybe_options) ) { + $options = $maybe_options; + } else if ( function_exists( 'optionsframework_options' ) ) { + $options = optionsframework_options(); + } + } + + // Allow setting/manipulating options via filters + $options = apply_filters('of_options', $options); + } + + return $options; +} + +/** + * Get Option. + * + * Helper function to return the theme option value. + * If no value has been saved, it returns $default. + * Needed because options are saved as serialized strings. + */ + +if ( ! function_exists( 'akina_option' ) ) { + + function akina_option( $name, $default = false ) { + $config = get_option( 'optionsframework' ); + + if ( ! isset( $config['id'] ) ) { + return $default; + } + + $options = get_option( $config['id'] ); + + if ( isset( $options[$name] ) ) { + return $options[$name]; + } + + return $default; + } +} \ No newline at end of file diff --git a/inc/options-interface.php b/inc/options-interface.php new file mode 100644 index 0000000..12e49c0 --- /dev/null +++ b/inc/options-interface.php @@ -0,0 +1,423 @@ +' . esc_html( $value['name'] ) . ''; + } + } + + return $menu; +} + +/** + * Generates the options fields that are used in the form. + */ + +function optionsframework_fields() { + + global $allowedtags; + $optionsframework_settings = get_option( 'optionsframework' ); + + // Gets the unique option id + if ( isset( $optionsframework_settings['id'] ) ) { + $option_name = $optionsframework_settings['id']; + } + else { + $option_name = 'options_framework_theme'; + }; + + $settings = get_option($option_name); + $options =& _optionsframework_options(); + + $counter = 0; + $menu = ''; + + foreach ( $options as $value ) { + + $val = ''; + $select_value = ''; + $output = ''; + + // Wrap all options + if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { + + // Keep all ids lowercase with no spaces + $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower( $value['id'] ) ); + + $id = 'section-' . $value['id']; + + $class = 'section'; + if ( isset( $value['type'] ) ) { + $class .= ' section-' . $value['type']; + } + if ( isset( $value['class'] ) ) { + $class .= ' ' . $value['class']; + } + + $output .= '
    '."\n"; + if ( isset( $value['name'] ) ) { + $output .= '

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

    ' . "\n"; + } + if ( $value['type'] != 'editor' ) { + $output .= '
    ' . "\n" . '
    ' . "\n"; + } + else { + $output .= '
    ' . "\n" . '
    ' . "\n"; + } + } + + // Set default value to $val + if ( isset( $value['std'] ) ) { + $val = $value['std']; + } + + // If the option is already saved, ovveride $val + if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) { + if ( isset( $settings[($value['id'])]) ) { + $val = $settings[($value['id'])]; + // Striping slashes of non-array options + if ( !is_array($val) ) { + $val = stripslashes( $val ); + } + } + } + + // If there is a description save it for labels + $explain_value = ''; + if ( isset( $value['desc'] ) ) { + $explain_value = $value['desc']; + } + + switch ( $value['type'] ) { + + // Basic text input + case 'text': + $output .= ''; + break; + + // Password input + case 'password': + $output .= ''; + break; + + // Textarea + case 'textarea': + $rows = '8'; + + if ( isset( $value['settings']['rows'] ) ) { + $custom_rows = $value['settings']['rows']; + if ( is_numeric( $custom_rows ) ) { + $rows = $custom_rows; + } + } + + $val = stripslashes( $val ); + $output .= ''; + break; + + // Select Box + case 'select': + $output .= ''; + break; + + + // Radio Box + case "radio": + $name = $option_name .'['. $value['id'] .']'; + foreach ($value['options'] as $key => $option) { + $id = $option_name . '-' . $value['id'] .'-'. $key; + $output .= ''; + } + break; + + // Image Selectors + case "images": + $name = $option_name .'['. $value['id'] .']'; + foreach ( $value['options'] as $key => $option ) { + $selected = ''; + if ( $val != '' && ($val == $key) ) { + $selected = ' of-radio-img-selected'; + } + $output .= ''; + $output .= '
    ' . esc_html( $key ) . '
    '; + $output .= '' . $option .''; + } + break; + + // colorradio Selectors + case "colorradio": + $name = $option_name .'['. $value['id'] .']'; + foreach ( $value['options'] as $key=>$key ) { + $selected = ''; + $checked = ''; + if ( $val != '' ) { + if ( $val == $key ) { + $selected = ' of-radio-img-selected'; + $checked = ' checked="checked"'; + } + } + $output .= ''; + $output .= '
    ' . esc_html( $key ) . '
    '; + $output .= ''; + // $output .= '' . $option .''; + } + break; + + // Checkbox + case "checkbox": + $output .= ''; + $output .= ''; + break; + + // Multicheck + case "multicheck": + foreach ($value['options'] as $key => $option) { + $checked = ''; + $label = $option; + $option = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($key)); + + $id = $option_name . '-' . $value['id'] . '-'. $option; + $name = $option_name . '[' . $value['id'] . '][' . $option .']'; + + if ( isset($val[$option]) ) { + $checked = checked($val[$option], 1, false); + } + + $output .= ''; + } + break; + + // Color picker + case "color": + $default_color = ''; + if ( isset($value['std']) ) { + if ( $val != $value['std'] ) + $default_color = ' data-default-color="' .$value['std'] . '" '; + } + $output .= ''; + + break; + + // Uploader + case "upload": + $output .= optionsframework_uploader( $value['id'], $val, null ); + + break; + + // Typography + case 'typography': + + unset( $font_size, $font_style, $font_face, $font_color ); + + $typography_defaults = array( + 'size' => '', + 'face' => '', + 'style' => '', + 'color' => '' + ); + + $typography_stored = wp_parse_args( $val, $typography_defaults ); + + $typography_options = array( + 'sizes' => of_recognized_font_sizes(), + 'faces' => of_recognized_font_faces(), + 'styles' => of_recognized_font_styles(), + 'color' => true + ); + + if ( isset( $value['options'] ) ) { + $typography_options = wp_parse_args( $value['options'], $typography_options ); + } + + // Font Size + if ( $typography_options['sizes'] ) { + $font_size = ''; + } + + // Font Face + if ( $typography_options['faces'] ) { + $font_face = ''; + } + + // Font Styles + if ( $typography_options['styles'] ) { + $font_style = ''; + } + + // Font Color + if ( $typography_options['color'] ) { + $default_color = ''; + if ( isset( $value['std']['color'] ) ) { + if ( $val != $value['std']['color'] ) + $default_color = ' data-default-color="' .$value['std']['color'] . '" '; + } + $font_color = ''; + } + + // Allow modification/injection of typography fields + $typography_fields = compact( 'font_size', 'font_face', 'font_style', 'font_color' ); + $typography_fields = apply_filters( 'of_typography_fields', $typography_fields, $typography_stored, $option_name, $value ); + $output .= implode( '', $typography_fields ); + + break; + + // Background + case 'background': + + $background = $val; + + // Background Color + $default_color = ''; + if ( isset( $value['std']['color'] ) ) { + if ( $val != $value['std']['color'] ) + $default_color = ' data-default-color="' .$value['std']['color'] . '" '; + } + $output .= ''; + + // Background Image + if (!isset($background['image'])) { + $background['image'] = ''; + } + + $output .= optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) ); + + $class = 'of-background-properties'; + if ( '' == $background['image'] ) { + $class .= ' hide'; + } + $output .= '
    '; + + // Background Repeat + $output .= ''; + + // Background Position + $output .= ''; + + // Background Attachment + $output .= ''; + $output .= '
    '; + + break; + + // Editor + case 'editor': + $output .= '
    ' . wp_kses( $explain_value, $allowedtags ) . '
    '."\n"; + echo $output; + $textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' ); + $default_editor_settings = array( + 'textarea_name' => $textarea_name, + 'media_buttons' => false, + 'tinymce' => array( 'plugins' => 'wordpress' ) + ); + $editor_settings = array(); + if ( isset( $value['settings'] ) ) { + $editor_settings = $value['settings']; + } + $editor_settings = array_merge( $default_editor_settings, $editor_settings ); + wp_editor( $val, $value['id'], $editor_settings ); + $output = ''; + break; + + // Info + case "info": + $id = ''; + $class = 'section'; + if ( isset( $value['id'] ) ) { + $id = 'id="' . esc_attr( $value['id'] ) . '" '; + } + if ( isset( $value['type'] ) ) { + $class .= ' section-' . $value['type']; + } + if ( isset( $value['class'] ) ) { + $class .= ' ' . $value['class']; + } + + $output .= '
    ' . "\n"; + if ( isset($value['name']) ) { + $output .= '

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

    ' . "\n"; + } + if ( $value['desc'] ) { + $output .= apply_filters('of_sanitize_info', $value['desc'] ) . "\n"; + } + $output .= '
    ' . "\n"; + break; + + // Heading for Navigation + case "heading": + $counter++; + if ($counter >= 2) { + $output .= '
    '."\n"; + } + $class = ''; + $class = ! empty( $value['id'] ) ? $value['id'] : $value['name']; + $class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) ); + $output .= '
    '; + $output .= '

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

    ' . "\n"; + break; + } + + if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) { + $output .= '
    '; + if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) { + $output .= '
    ' . wp_kses( $explain_value, $allowedtags ) . '
    '."\n"; + } + $output .= '
    '."\n"; + } + + echo $output; + } + echo '
    '; +} \ No newline at end of file diff --git a/inc/options-media-uploader.php b/inc/options-media-uploader.php new file mode 100644 index 0000000..6531372 --- /dev/null +++ b/inc/options-media-uploader.php @@ -0,0 +1,118 @@ +' . "\n"; + if ( function_exists( 'wp_enqueue_media' ) ) { + if ( ( $value == '' ) ) { + $output .= '' . "\n"; + } else { + $output .= '' . "\n"; + } + } else { + $output .= '

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

    '; + } + + if ( $_desc != '' ) { + $output .= '' . $_desc . '' . "\n"; + } + + $output .= '
    ' . "\n"; + + if ( $value != '' ) { + $remove = 'Remove'; + $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value ); + if ( $image ) { + $output .= ''.$remove.''; + } else { + $parts = explode( "/", $value ); + for( $i = 0; $i < sizeof( $parts ); ++$i ) { + $title = $parts[$i]; + } + + // No output preview if it's not an image. + $output .= ''; + + // Standard generic output if it's not an image. + $title = __( 'View File', 'options_framework_theme' ); + $output .= ''; + } + } + $output .= '
    ' . "\n"; + return $output; +} + +endif; + +/** + * Enqueue scripts for file uploader + */ + +if ( ! function_exists( 'optionsframework_media_scripts' ) ) : + +add_action( 'admin_enqueue_scripts', 'optionsframework_media_scripts' ); + +function optionsframework_media_scripts( $hook ) { + + $menu = optionsframework_menu_settings(); + + if ( 'appearance_page_' . $menu['menu_slug'] != $hook ) + return; + + if ( function_exists( 'wp_enqueue_media' ) ) + wp_enqueue_media(); + wp_register_script( 'of-media-uploader', OPTIONS_FRAMEWORK_DIRECTORY .'js/media-uploader.js', array( 'jquery' ) ); + wp_enqueue_script( 'of-media-uploader' ); + wp_localize_script( 'of-media-uploader', 'optionsframework_l10n', array( + 'upload' => __( '上传', 'options_framework_theme' ), + 'remove' => __( '移除', 'options_framework_theme' ) + ) ); +} + +endif; diff --git a/inc/options-sanitize.php b/inc/options-sanitize.php new file mode 100644 index 0000000..97f11e6 --- /dev/null +++ b/inc/options-sanitize.php @@ -0,0 +1,248 @@ + $value ) { + $output[$key] = "0"; + } + foreach( $input as $key => $value ) { + if ( array_key_exists( $key, $option['options'] ) && $value ) { + $output[$key] = "1"; + } + } + } + return $output; +} +add_filter( 'of_sanitize_multicheck', 'of_sanitize_multicheck', 10, 2 ); +add_filter( 'of_sanitize_color', 'of_sanitize_hex' ); +function of_sanitize_upload( $input ) { + $output = ''; + $filetype = wp_check_filetype($input); + if ( $filetype["ext"] ) { + $output = $input; + } + return $output; +} +add_filter( 'of_sanitize_upload', 'of_sanitize_upload' ); +function of_sanitize_editor($input) { + if ( current_user_can( 'unfiltered_html' ) ) { + $output = $input; + } + else { + global $allowedtags; + $output = wpautop(wp_kses( $input, $allowedtags)); + } + return $output; +} +add_filter( 'of_sanitize_editor', 'of_sanitize_editor' ); +function of_sanitize_allowedtags($input) { + global $allowedtags; + $output = wpautop(wp_kses( $input, $allowedtags)); + return $output; +} +function of_sanitize_allowedposttags($input) { + global $allowedposttags; + $output = wpautop(wp_kses( $input, $allowedposttags)); + return $output; +} + +add_filter( 'of_sanitize_info', 'of_sanitize_allowedposttags' ); +function of_sanitize_enum( $input, $option ) { + $output = ''; + if ( array_key_exists( $input, $option['options'] ) ) { + $output = $input; + } + return $output; +} +function of_sanitize_background( $input ) { + $output = wp_parse_args( $input, array( + 'color' => '', + 'image' => '', + 'repeat' => 'repeat', + 'position' => 'top center', + 'attachment' => 'scroll' + ) ); + + $output['color'] = apply_filters( 'of_sanitize_hex', $input['color'] ); + $output['image'] = apply_filters( 'of_sanitize_upload', $input['image'] ); + $output['repeat'] = apply_filters( 'of_background_repeat', $input['repeat'] ); + $output['position'] = apply_filters( 'of_background_position', $input['position'] ); + $output['attachment'] = apply_filters( 'of_background_attachment', $input['attachment'] ); + + return $output; +} +add_filter( 'of_sanitize_background', 'of_sanitize_background' ); +function of_sanitize_background_repeat( $value ) { + $recognized = of_recognized_background_repeat(); + if ( array_key_exists( $value, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_background_repeat', current( $recognized ) ); +} +add_filter( 'of_background_repeat', 'of_sanitize_background_repeat' ); + +function of_sanitize_background_position( $value ) { + $recognized = of_recognized_background_position(); + if ( array_key_exists( $value, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_background_position', current( $recognized ) ); +} +add_filter( 'of_background_position', 'of_sanitize_background_position' ); + +function of_sanitize_background_attachment( $value ) { + $recognized = of_recognized_background_attachment(); + if ( array_key_exists( $value, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_background_attachment', current( $recognized ) ); +} +add_filter( 'of_background_attachment', 'of_sanitize_background_attachment' ); +function of_sanitize_typography( $input, $option ) { + + $output = wp_parse_args( $input, array( + 'size' => '', + 'face' => '', + 'style' => '', + 'color' => '' + ) ); + + if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) { + if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) { + $output['face'] = ''; + } + } + else { + $output['face'] = apply_filters( 'of_font_face', $output['face'] ); + } + + $output['size'] = apply_filters( 'of_font_size', $output['size'] ); + $output['style'] = apply_filters( 'of_font_style', $output['style'] ); + $output['color'] = apply_filters( 'of_sanitize_color', $output['color'] ); + return $output; +} +add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 ); +function of_sanitize_font_size( $value ) { + $recognized = of_recognized_font_sizes(); + $value_check = preg_replace('/px/','', $value); + if ( in_array( (int) $value_check, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_font_size', $recognized ); +} +add_filter( 'of_font_size', 'of_sanitize_font_size' ); +function of_sanitize_font_style( $value ) { + $recognized = of_recognized_font_styles(); + if ( array_key_exists( $value, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_font_style', current( $recognized ) ); +} +add_filter( 'of_font_style', 'of_sanitize_font_style' ); +function of_sanitize_font_face( $value ) { + $recognized = of_recognized_font_faces(); + if ( array_key_exists( $value, $recognized ) ) { + return $value; + } + return apply_filters( 'of_default_font_face', current( $recognized ) ); +} +add_filter( 'of_font_face', 'of_sanitize_font_face' ); +function of_recognized_background_repeat() { + $default = array( + 'no-repeat' =>'不重复填充', + 'repeat-x' =>'水平重复填充', + 'repeat-y' =>'垂直重复填充', + 'repeat' =>'重复填充' + ); + return apply_filters( 'of_recognized_background_repeat', $default ); +} +function of_recognized_background_position() { + $default = array( + 'top left' =>'上左对齐', + 'top center' =>'上中对齐', + 'top right' =>'上右对齐', + 'center left' =>'中左对齐', + 'center center' =>'中中对齐', + 'center right' =>'中右对齐', + 'bottom left' =>'下左对齐', + 'bottom center' =>'下中对齐', + 'bottom right' =>'下右对齐' + ); + return apply_filters( 'of_recognized_background_position', $default ); +} +function of_recognized_background_attachment() { + $default = array( + 'scroll' =>'固定', + 'fixed' => '滚动' + ); + return apply_filters( 'of_recognized_background_attachment', $default ); +} +function of_sanitize_hex( $hex, $default = '' ) { + if ( of_validate_hex( $hex ) ) { + return $hex; + } + return $default; +} +function of_recognized_font_sizes() { + $sizes = range( 12,24,2); + $sizes = apply_filters( 'of_recognized_font_sizes', $sizes ); + $sizes = array_map( 'absint', $sizes ); + return $sizes; +} +function of_recognized_font_faces() { + $default = array( + 'arial' => 'Arial', + 'verdana' => 'Verdana, Geneva', + 'trebuchet' => 'Trebuchet', + 'georgia' => 'Georgia', + 'times' => 'Times New Roman', + 'tahoma' => 'Tahoma, Geneva', + 'palatino' => 'Palatino', + 'helvetica' => 'Helvetica*' + ); + return apply_filters( 'of_recognized_font_faces', $default ); +} +function of_recognized_font_styles() { + $default = array( + 'normal' => '普通', + 'italic' => '斜体', + 'bold' => '粗体', + 'bold italic' => '斜体+粗体' + ); + return apply_filters( 'of_recognized_font_styles', $default ); +} +function of_validate_hex( $hex ) { + $hex = trim( $hex ); + if ( 0 === strpos( $hex, '#' ) ) { + $hex = substr( $hex, 1 ); + } + elseif ( 0 === strpos( $hex, '%23' ) ) { + $hex = substr( $hex, 3 ); + } + if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) { + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/inc/scssphp--old/LICENSE.md b/inc/scssphp--old/LICENSE.md new file mode 100644 index 0000000..2f5412f --- /dev/null +++ b/inc/scssphp--old/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2015 Leaf Corcoran, http://leafo.github.io/scssphp + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/inc/scssphp--old/README.md b/inc/scssphp--old/README.md new file mode 100644 index 0000000..53a4c7a --- /dev/null +++ b/inc/scssphp--old/README.md @@ -0,0 +1,47 @@ +# scssphp +### + +[![Build](https://travis-ci.org/leafo/scssphp.svg?branch=master)](http://travis-ci.org/leafo/scssphp) +[![License](https://poser.pugx.org/leafo/scssphp/license.svg)](https://packagist.org/packages/leafo/scssphp) + +`scssphp` is a compiler for SCSS written in PHP. + +Checkout the homepage, , for directions on how to use. + +## Running Tests + +`scssphp` uses [PHPUnit](https://github.com/sebastianbergmann/phpunit) for testing. + +Run the following command from the root directory to run every test: + + vendor/bin/phpunit tests + +There are several tests in the `tests/` directory: + +* `ApiTest.php` contains various unit tests that test the PHP interface. +* `ExceptionTest.php` contains unit tests that test for exceptions thrown by the parser and compiler. +* `FailingTest.php` contains tests reported in Github issues that demonstrate compatibility bugs. +* `InputTest.php` compiles every `.scss` file in the `tests/inputs` directory + then compares to the respective `.css` file in the `tests/outputs` directory. +* `ScssTest.php` extracts (ruby) `scss` tests from the `tests/scss_test.rb` file. +* `ServerTest.php` contains functional tests for the `Server` class. + +When changing any of the tests in `tests/inputs`, the tests will most likely +fail because the output has changed. Once you verify that the output is correct +you can run the following command to rebuild all the tests: + + BUILD=1 vendor/bin/phpunit tests + +This will compile all the tests, and save results into `tests/outputs`. + +To enable the `scss` compatibility tests: + + TEST_SCSS_COMPAT=1 vendor/bin/phpunit tests + +## Coding Standard + +`scssphp` source conforms to [PSR2](http://www.php-fig.org/psr/psr-2/). + +Run the following command from the root directory to check the code for "sniffs". + + vendor/bin/phpcs --standard=PSR2 bin src tests diff --git a/inc/scssphp--old/bin/pscss b/inc/scssphp--old/bin/pscss new file mode 100644 index 0000000..be1cb51 --- /dev/null +++ b/inc/scssphp--old/bin/pscss @@ -0,0 +1,215 @@ +#!/usr/bin/env php +parse($data)), true)); + + exit(); +} + +$scss = new Compiler(); + +if ($debugInfo) { + $scss->setLineNumberStyle(Compiler::DEBUG_INFO); +} + +if ($lineNumbers) { + $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); +} + +if ($ignoreErrors) { + $scss->setIgnoreErrors($ignoreErrors); +} + +if ($loadPaths) { + $scss->setImportPaths(explode(PATH_SEPARATOR, $loadPaths)); +} + +if ($precision) { + $scss->setNumberPrecision($precision); +} + +if ($style) { + $scss->setFormatter('Leafo\\ScssPhp\\Formatter\\' . ucfirst($style)); +} + +if ($sourceMap) { + $scss->setSourceMap(Compiler::SOURCE_MAP_FILE); +} + +if ($encoding) { + $scss->setEncoding($encoding); +} + +echo $scss->compile($data, $inputFile); + +if ($changeDir) { + chdir($oldWorkingDir); +} diff --git a/inc/scssphp--old/composer.json b/inc/scssphp--old/composer.json new file mode 100644 index 0000000..95118a3 --- /dev/null +++ b/inc/scssphp--old/composer.json @@ -0,0 +1,41 @@ +{ + "name": "leafo/scssphp", + "type": "library", + "description": "scssphp is a compiler for SCSS written in PHP.", + "keywords": ["css", "stylesheet", "scss", "sass", "less"], + "homepage": "http://leafo.github.io/scssphp/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Leaf Corcoran", + "email": "leafot@gmail.com", + "homepage": "http://leafo.net" + } + ], + "autoload": { + "psr-4": { "Leafo\\ScssPhp\\": "src/" } + }, + "autoload-dev": { + "psr-4": { "Leafo\\ScssPhp\\Test\\": "tests/" } + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "~2.5", + "phpunit/phpunit": "~4.6" + }, + "bin": ["bin/pscss"], + "archive": { + "exclude": [ + "/Makefile", + "/.gitattributes", + "/.gitignore", + "/.travis.yml", + "/phpunit.xml.dist", + "/tests" + ] + } +} diff --git a/inc/scssphp--old/example/Server.php b/inc/scssphp--old/example/Server.php new file mode 100644 index 0000000..a8dc045 --- /dev/null +++ b/inc/scssphp--old/example/Server.php @@ -0,0 +1,517 @@ + + */ +class Server +{ + /** + * @var boolean + */ + private $showErrorsAsCSS; + + /** + * @var string + */ + private $dir; + + /** + * @var string + */ + private $cacheDir; + + /** + * @var \Leafo\ScssPhp\Compiler + */ + private $scss; + + /** + * Join path components + * + * @param string $left Path component, left of the directory separator + * @param string $right Path component, right of the directory separator + * + * @return string + */ + protected function join($left, $right) + { + return rtrim($left, '/\\') . DIRECTORY_SEPARATOR . ltrim($right, '/\\'); + } + + /** + * Get name of requested .scss file + * + * @return string|null + */ + protected function inputName() + { + switch (true) { + case isset($_GET['p']): + return $_GET['p']; + case isset($_SERVER['PATH_INFO']): + return $_SERVER['PATH_INFO']; + case isset($_SERVER['DOCUMENT_URI']): + return substr($_SERVER['DOCUMENT_URI'], strlen($_SERVER['SCRIPT_NAME'])); + } + } + + /** + * Get path to requested .scss file + * + * @return string + */ + protected function findInput() + { + if (($input = $this->inputName()) + && strpos($input, '..') === false + && substr($input, -5) === '.scss' + ) { + $name = $this->join($this->dir, $input); + + if (is_file($name) && is_readable($name)) { + return $name; + } + } + + return false; + } + + /** + * Get path to cached .css file + * + * @return string + */ + protected function cacheName($fname) + { + return $this->join($this->cacheDir, md5($fname) . '.css'); + } + + /** + * Get path to meta data + * + * @return string + */ + protected function metadataName($out) + { + return $out . '.meta'; + } + + /** + * Determine whether .scss file needs to be re-compiled. + * + * @param string $out Output path + * @param string $etag ETag + * + * @return boolean True if compile required. + */ + protected function needsCompile($out, &$etag) + { + if (! is_file($out)) { + return true; + } + + $mtime = filemtime($out); + + $metadataName = $this->metadataName($out); + + if (is_readable($metadataName)) { + $metadata = unserialize(file_get_contents($metadataName)); + + foreach ($metadata['imports'] as $import => $originalMtime) { + $currentMtime = filemtime($import); + + if ($currentMtime !== $originalMtime || $currentMtime > $mtime) { + return true; + } + } + + $metaVars = crc32(serialize($this->scss->getVariables())); + + if ($metaVars !== $metadata['vars']) { + return true; + } + + $etag = $metadata['etag']; + + return false; + } + + return true; + } + + /** + * Get If-Modified-Since header from client request + * + * @return string|null + */ + protected function getIfModifiedSinceHeader() + { + $modifiedSince = null; + + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { + $modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE']; + + if (false !== ($semicolonPos = strpos($modifiedSince, ';'))) { + $modifiedSince = substr($modifiedSince, 0, $semicolonPos); + } + } + + return $modifiedSince; + } + + /** + * Get If-None-Match header from client request + * + * @return string|null + */ + protected function getIfNoneMatchHeader() + { + $noneMatch = null; + + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { + $noneMatch = $_SERVER['HTTP_IF_NONE_MATCH']; + } + + return $noneMatch; + } + + /** + * Compile .scss file + * + * @param string $in Input path (.scss) + * @param string $out Output path (.css) + * + * @return array + */ + protected function compile($in, $out) + { + $start = microtime(true); + $css = $this->scss->compile(file_get_contents($in), $in); + $elapsed = round((microtime(true) - $start), 4); + + $v = Version::VERSION; + $t = date('r'); + $css = "/* compiled by scssphp $v on $t (${elapsed}s) */\n\n" . $css; + $etag = md5($css); + + file_put_contents($out, $css); + file_put_contents( + $this->metadataName($out), + serialize([ + 'etag' => $etag, + 'imports' => $this->scss->getParsedFiles(), + 'vars' => crc32(serialize($this->scss->getVariables())), + ]) + ); + + return [$css, $etag]; + } + + /** + * Format error as a pseudo-element in CSS + * + * @param \Exception $error + * + * @return string + */ + protected function createErrorCSS(\Exception $error) + { + $message = str_replace( + ["'", "\n"], + ["\\'", "\\A"], + $error->getfile() . ":\n\n" . $error->getMessage() + ); + + return "body { display: none !important; } + html:after { + background: white; + color: black; + content: '$message'; + display: block !important; + font-family: mono; + padding: 1em; + white-space: pre; + }"; + } + + /** + * Render errors as a pseudo-element within valid CSS, displaying the errors on any + * page that includes this CSS. + * + * @param boolean $show + */ + public function showErrorsAsCSS($show = true) + { + $this->showErrorsAsCSS = $show; + } + + /** + * Compile .scss file + * + * @param string $in Input file (.scss) + * @param string $out Output file (.css) optional + * + * @return string|bool + * + * @throws \Leafo\ScssPhp\Exception\ServerException + */ + public function compileFile($in, $out = null) + { + if (! is_readable($in)) { + throw new ServerException('load error: failed to find ' . $in); + } + + $pi = pathinfo($in); + + $this->scss->addImportPath($pi['dirname'] . '/'); + + $compiled = $this->scss->compile(file_get_contents($in), $in); + + if ($out !== null) { + return file_put_contents($out, $compiled); + } + + return $compiled; + } + + /** + * Check if file need compiling + * + * @param string $in Input file (.scss) + * @param string $out Output file (.css) + * + * @return bool + */ + public function checkedCompile($in, $out) + { + if (! is_file($out) || filemtime($in) > filemtime($out)) { + $this->compileFile($in, $out); + + return true; + } + + return false; + } + + /** + * Compile requested scss and serve css. Outputs HTTP response. + * + * @param string $salt Prefix a string to the filename for creating the cache name hash + */ + public function serve($salt = '') + { + $protocol = isset($_SERVER['SERVER_PROTOCOL']) + ? $_SERVER['SERVER_PROTOCOL'] + : 'HTTP/1.0'; + + if ($input = $this->findInput()) { + $output = $this->cacheName($salt . $input); + $etag = $noneMatch = trim($this->getIfNoneMatchHeader(), '"'); + + if ($this->needsCompile($output, $etag)) { + try { + list($css, $etag) = $this->compile($input, $output); + + $lastModified = gmdate('D, d M Y H:i:s', filemtime($output)) . ' GMT'; + + header('Last-Modified: ' . $lastModified); + header('Content-type: text/css'); + header('ETag: "' . $etag . '"'); + + echo $css; + } catch (\Exception $e) { + if ($this->showErrorsAsCSS) { + header('Content-type: text/css'); + + echo $this->createErrorCSS($e); + } else { + header($protocol . ' 500 Internal Server Error'); + header('Content-type: text/plain'); + + echo 'Parse error: ' . $e->getMessage() . "\n"; + } + } + + return; + } + + header('X-SCSS-Cache: true'); + header('Content-type: text/css'); + header('ETag: "' . $etag . '"'); + + if ($etag === $noneMatch) { + header($protocol . ' 304 Not Modified'); + + return; + } + + $modifiedSince = $this->getIfModifiedSinceHeader(); + $mtime = filemtime($output); + + if (strtotime($modifiedSince) === $mtime) { + header($protocol . ' 304 Not Modified'); + + return; + } + + $lastModified = gmdate('D, d M Y H:i:s', $mtime) . ' GMT'; + header('Last-Modified: ' . $lastModified); + + echo file_get_contents($output); + + return; + } + + header($protocol . ' 404 Not Found'); + header('Content-type: text/plain'); + + $v = Version::VERSION; + echo "/* INPUT NOT FOUND scss $v */\n"; + } + + /** + * Based on explicit input/output files does a full change check on cache before compiling. + * + * @param string $in + * @param string $out + * @param boolean $force + * + * @return string Compiled CSS results + * + * @throws \Leafo\ScssPhp\Exception\ServerException + */ + public function checkedCachedCompile($in, $out, $force = false) + { + if (! is_file($in) || ! is_readable($in)) { + throw new ServerException('Invalid or unreadable input file specified.'); + } + + if (is_dir($out) || ! is_writable(file_exists($out) ? $out : dirname($out))) { + throw new ServerException('Invalid or unwritable output file specified.'); + } + + if ($force || $this->needsCompile($out, $etag)) { + list($css, $etag) = $this->compile($in, $out); + } else { + $css = file_get_contents($out); + } + + return $css; + } + + /** + * Execute scssphp on a .scss file or a scssphp cache structure + * + * The scssphp cache structure contains information about a specific + * scss file having been parsed. It can be used as a hint for future + * calls to determine whether or not a rebuild is required. + * + * The cache structure contains two important keys that may be used + * externally: + * + * compiled: The final compiled CSS + * updated: The time (in seconds) the CSS was last compiled + * + * The cache structure is a plain-ol' PHP associative array and can + * be serialized and unserialized without a hitch. + * + * @param mixed $in Input + * @param boolean $force Force rebuild? + * + * @return array scssphp cache structure + */ + public function cachedCompile($in, $force = false) + { + // assume no root + $root = null; + + if (is_string($in)) { + $root = $in; + } elseif (is_array($in) and isset($in['root'])) { + if ($force or ! isset($in['files'])) { + // If we are forcing a recompile or if for some reason the + // structure does not contain any file information we should + // specify the root to trigger a rebuild. + $root = $in['root']; + } elseif (isset($in['files']) and is_array($in['files'])) { + foreach ($in['files'] as $fname => $ftime) { + if (! file_exists($fname) or filemtime($fname) > $ftime) { + // One of the files we knew about previously has changed + // so we should look at our incoming root again. + $root = $in['root']; + break; + } + } + } + } else { + // TODO: Throw an exception? We got neither a string nor something + // that looks like a compatible lessphp cache structure. + return null; + } + + if ($root !== null) { + // If we have a root value which means we should rebuild. + $out = array(); + $out['root'] = $root; + $out['compiled'] = $this->compileFile($root); + $out['files'] = $this->scss->getParsedFiles(); + $out['updated'] = time(); + return $out; + } else { + // No changes, pass back the structure + // we were given initially. + return $in; + } + } + + /** + * Constructor + * + * @param string $dir Root directory to .scss files + * @param string $cacheDir Cache directory + * @param \Leafo\ScssPhp\Compiler|null $scss SCSS compiler instance + */ + public function __construct($dir, $cacheDir = null, $scss = null) + { + $this->dir = $dir; + + if (! isset($cacheDir)) { + $cacheDir = $this->join($dir, 'scss_cache'); + } + + $this->cacheDir = $cacheDir; + + if (! is_dir($this->cacheDir)) { + throw new ServerException('Cache directory doesn\'t exist: ' . $cacheDir); + } + + if (! isset($scss)) { + $scss = new Compiler(); + $scss->setImportPaths($this->dir); + } + + $this->scss = $scss; + $this->showErrorsAsCSS = false; + + if (! ini_get('date.timezone')) { + throw new ServerException('Default date.timezone not set'); + } + } +} diff --git a/inc/scssphp--old/scss.inc.php b/inc/scssphp--old/scss.inc.php new file mode 100644 index 0000000..13c84bf --- /dev/null +++ b/inc/scssphp--old/scss.inc.php @@ -0,0 +1,32 @@ + + */ +class Range +{ + public $first; + public $last; + + /** + * Initialize range + * + * @param integer|float $first + * @param integer|float $last + */ + public function __construct($first, $last) + { + $this->first = $first; + $this->last = $last; + } + + /** + * Test for inclusion in range + * + * @param integer|float $value + * + * @return boolean + */ + public function includes($value) + { + return $value >= $this->first && $value <= $this->last; + } +} diff --git a/inc/scssphp--old/src/Block.php b/inc/scssphp--old/src/Block.php new file mode 100644 index 0000000..a6ef8e0 --- /dev/null +++ b/inc/scssphp--old/src/Block.php @@ -0,0 +1,65 @@ + + */ +class Block +{ + /** + * @var string + */ + public $type; + + /** + * @var \Leafo\ScssPhp\Block + */ + public $parent; + + /** + * @var string + */ + public $sourceName; + + /** + * @var integer + */ + public $sourceIndex; + + /** + * @var integer + */ + public $sourceLine; + + /** + * @var integer + */ + public $sourceColumn; + + /** + * @var array + */ + public $selectors; + + /** + * @var array + */ + public $comments; + + /** + * @var array + */ + public $children; +} diff --git a/inc/scssphp--old/src/Colors.php b/inc/scssphp--old/src/Colors.php new file mode 100644 index 0000000..2314ea5 --- /dev/null +++ b/inc/scssphp--old/src/Colors.php @@ -0,0 +1,179 @@ + + */ +class Colors +{ + /** + * CSS Colors + * + * @see http://www.w3.org/TR/css3-color + * + * @var array + */ + public static $cssColors = [ + 'aliceblue' => '240,248,255', + 'antiquewhite' => '250,235,215', + 'aqua' => '0,255,255', + 'aquamarine' => '127,255,212', + 'azure' => '240,255,255', + 'beige' => '245,245,220', + 'bisque' => '255,228,196', + 'black' => '0,0,0', + 'blanchedalmond' => '255,235,205', + 'blue' => '0,0,255', + 'blueviolet' => '138,43,226', + 'brown' => '165,42,42', + 'burlywood' => '222,184,135', + 'cadetblue' => '95,158,160', + 'chartreuse' => '127,255,0', + 'chocolate' => '210,105,30', + 'coral' => '255,127,80', + 'cornflowerblue' => '100,149,237', + 'cornsilk' => '255,248,220', + 'crimson' => '220,20,60', + 'cyan' => '0,255,255', + 'darkblue' => '0,0,139', + 'darkcyan' => '0,139,139', + 'darkgoldenrod' => '184,134,11', + 'darkgray' => '169,169,169', + 'darkgreen' => '0,100,0', + 'darkgrey' => '169,169,169', + 'darkkhaki' => '189,183,107', + 'darkmagenta' => '139,0,139', + 'darkolivegreen' => '85,107,47', + 'darkorange' => '255,140,0', + 'darkorchid' => '153,50,204', + 'darkred' => '139,0,0', + 'darksalmon' => '233,150,122', + 'darkseagreen' => '143,188,143', + 'darkslateblue' => '72,61,139', + 'darkslategray' => '47,79,79', + 'darkslategrey' => '47,79,79', + 'darkturquoise' => '0,206,209', + 'darkviolet' => '148,0,211', + 'deeppink' => '255,20,147', + 'deepskyblue' => '0,191,255', + 'dimgray' => '105,105,105', + 'dimgrey' => '105,105,105', + 'dodgerblue' => '30,144,255', + 'firebrick' => '178,34,34', + 'floralwhite' => '255,250,240', + 'forestgreen' => '34,139,34', + 'fuchsia' => '255,0,255', + 'gainsboro' => '220,220,220', + 'ghostwhite' => '248,248,255', + 'gold' => '255,215,0', + 'goldenrod' => '218,165,32', + 'gray' => '128,128,128', + 'green' => '0,128,0', + 'greenyellow' => '173,255,47', + 'grey' => '128,128,128', + 'honeydew' => '240,255,240', + 'hotpink' => '255,105,180', + 'indianred' => '205,92,92', + 'indigo' => '75,0,130', + 'ivory' => '255,255,240', + 'khaki' => '240,230,140', + 'lavender' => '230,230,250', + 'lavenderblush' => '255,240,245', + 'lawngreen' => '124,252,0', + 'lemonchiffon' => '255,250,205', + 'lightblue' => '173,216,230', + 'lightcoral' => '240,128,128', + 'lightcyan' => '224,255,255', + 'lightgoldenrodyellow' => '250,250,210', + 'lightgray' => '211,211,211', + 'lightgreen' => '144,238,144', + 'lightgrey' => '211,211,211', + 'lightpink' => '255,182,193', + 'lightsalmon' => '255,160,122', + 'lightseagreen' => '32,178,170', + 'lightskyblue' => '135,206,250', + 'lightslategray' => '119,136,153', + 'lightslategrey' => '119,136,153', + 'lightsteelblue' => '176,196,222', + 'lightyellow' => '255,255,224', + 'lime' => '0,255,0', + 'limegreen' => '50,205,50', + 'linen' => '250,240,230', + 'magenta' => '255,0,255', + 'maroon' => '128,0,0', + 'mediumaquamarine' => '102,205,170', + 'mediumblue' => '0,0,205', + 'mediumorchid' => '186,85,211', + 'mediumpurple' => '147,112,219', + 'mediumseagreen' => '60,179,113', + 'mediumslateblue' => '123,104,238', + 'mediumspringgreen' => '0,250,154', + 'mediumturquoise' => '72,209,204', + 'mediumvioletred' => '199,21,133', + 'midnightblue' => '25,25,112', + 'mintcream' => '245,255,250', + 'mistyrose' => '255,228,225', + 'moccasin' => '255,228,181', + 'navajowhite' => '255,222,173', + 'navy' => '0,0,128', + 'oldlace' => '253,245,230', + 'olive' => '128,128,0', + 'olivedrab' => '107,142,35', + 'orange' => '255,165,0', + 'orangered' => '255,69,0', + 'orchid' => '218,112,214', + 'palegoldenrod' => '238,232,170', + 'palegreen' => '152,251,152', + 'paleturquoise' => '175,238,238', + 'palevioletred' => '219,112,147', + 'papayawhip' => '255,239,213', + 'peachpuff' => '255,218,185', + 'peru' => '205,133,63', + 'pink' => '255,192,203', + 'plum' => '221,160,221', + 'powderblue' => '176,224,230', + 'purple' => '128,0,128', + 'rebeccapurple' => '102,51,153', + 'red' => '255,0,0', + 'rosybrown' => '188,143,143', + 'royalblue' => '65,105,225', + 'saddlebrown' => '139,69,19', + 'salmon' => '250,128,114', + 'sandybrown' => '244,164,96', + 'seagreen' => '46,139,87', + 'seashell' => '255,245,238', + 'sienna' => '160,82,45', + 'silver' => '192,192,192', + 'skyblue' => '135,206,235', + 'slateblue' => '106,90,205', + 'slategray' => '112,128,144', + 'slategrey' => '112,128,144', + 'snow' => '255,250,250', + 'springgreen' => '0,255,127', + 'steelblue' => '70,130,180', + 'tan' => '210,180,140', + 'teal' => '0,128,128', + 'thistle' => '216,191,216', + 'tomato' => '255,99,71', + 'transparent' => '0,0,0,0', + 'turquoise' => '64,224,208', + 'violet' => '238,130,238', + 'wheat' => '245,222,179', + 'white' => '255,255,255', + 'whitesmoke' => '245,245,245', + 'yellow' => '255,255,0', + 'yellowgreen' => '154,205,50', + ]; +} diff --git a/inc/scssphp--old/src/Compiler.php b/inc/scssphp--old/src/Compiler.php new file mode 100644 index 0000000..292e960 --- /dev/null +++ b/inc/scssphp--old/src/Compiler.php @@ -0,0 +1,5336 @@ + + */ +class Compiler +{ + const LINE_COMMENTS = 1; + const DEBUG_INFO = 2; + + const WITH_RULE = 1; + const WITH_MEDIA = 2; + const WITH_SUPPORTS = 4; + const WITH_ALL = 7; + + const SOURCE_MAP_NONE = 0; + const SOURCE_MAP_INLINE = 1; + const SOURCE_MAP_FILE = 2; + + /** + * @var array + */ + static protected $operatorNames = [ + '+' => 'add', + '-' => 'sub', + '*' => 'mul', + '/' => 'div', + '%' => 'mod', + + '==' => 'eq', + '!=' => 'neq', + '<' => 'lt', + '>' => 'gt', + + '<=' => 'lte', + '>=' => 'gte', + '<=>' => 'cmp', + ]; + + /** + * @var array + */ + static protected $namespaces = [ + 'special' => '%', + 'mixin' => '@', + 'function' => '^', + ]; + + static public $true = [Type::T_KEYWORD, 'true']; + static public $false = [Type::T_KEYWORD, 'false']; + static public $null = [Type::T_NULL]; + static public $nullString = [Type::T_STRING, '', []]; + static public $defaultValue = [Type::T_KEYWORD, '']; + static public $selfSelector = [Type::T_SELF]; + static public $emptyList = [Type::T_LIST, '', []]; + static public $emptyMap = [Type::T_MAP, [], []]; + static public $emptyString = [Type::T_STRING, '"', []]; + static public $with = [Type::T_KEYWORD, 'with']; + static public $without = [Type::T_KEYWORD, 'without']; + + protected $importPaths = ['']; + protected $importCache = []; + protected $importedFiles = []; + protected $userFunctions = []; + protected $registeredVars = []; + protected $registeredFeatures = [ + 'extend-selector-pseudoclass' => false, + 'at-error' => true, + 'units-level-3' => false, + 'global-variable-shadowing' => false, + ]; + + protected $encoding = null; + protected $lineNumberStyle = null; + + protected $sourceMap = self::SOURCE_MAP_NONE; + protected $sourceMapOptions = []; + + /** + * @var string|\Leafo\ScssPhp\Formatter + */ + protected $formatter = 'Leafo\ScssPhp\Formatter\Nested'; + + protected $rootEnv; + protected $rootBlock; + + /** + * @var \Leafo\ScssPhp\Compiler\Environment + */ + protected $env; + protected $scope; + protected $storeEnv; + protected $charsetSeen; + protected $sourceNames; + + private $indentLevel; + private $commentsSeen; + private $extends; + private $extendsMap; + private $parsedFiles; + private $parser; + private $sourceIndex; + private $sourceLine; + private $sourceColumn; + private $stderr; + private $shouldEvaluate; + private $ignoreErrors; + + /** + * Constructor + */ + public function __construct() + { + $this->parsedFiles = []; + $this->sourceNames = []; + } + + /** + * Compile scss + * + * @api + * + * @param string $code + * @param string $path + * + * @return string + */ + public function compile($code, $path = null) + { + $this->indentLevel = -1; + $this->commentsSeen = []; + $this->extends = []; + $this->extendsMap = []; + $this->sourceIndex = null; + $this->sourceLine = null; + $this->sourceColumn = null; + $this->env = null; + $this->scope = null; + $this->storeEnv = null; + $this->charsetSeen = null; + $this->shouldEvaluate = null; + $this->stderr = fopen('php://stderr', 'w'); + + $this->parser = $this->parserFactory($path); + $tree = $this->parser->parse($code); + $this->parser = null; + + $this->formatter = new $this->formatter(); + $this->rootBlock = null; + $this->rootEnv = $this->pushEnv($tree); + + $this->injectVariables($this->registeredVars); + $this->compileRoot($tree); + $this->popEnv(); + + $sourceMapGenerator = null; + + if ($this->sourceMap) { + if (is_object($this->sourceMap) && $this->sourceMap instanceof SourceMapGenerator) { + $sourceMapGenerator = $this->sourceMap; + $this->sourceMap = self::SOURCE_MAP_FILE; + } elseif ($this->sourceMap !== self::SOURCE_MAP_NONE) { + $sourceMapGenerator = new SourceMapGenerator($this->sourceMapOptions); + } + } + + $out = $this->formatter->format($this->scope, $sourceMapGenerator); + + if (! empty($out) && $this->sourceMap && $this->sourceMap !== self::SOURCE_MAP_NONE) { + $sourceMap = $sourceMapGenerator->generateJson(); + $sourceMapUrl = null; + + switch ($this->sourceMap) { + case self::SOURCE_MAP_INLINE: + $sourceMapUrl = sprintf('data:application/json,%s', Util::encodeURIComponent($sourceMap)); + break; + + case self::SOURCE_MAP_FILE: + $sourceMapUrl = $sourceMapGenerator->saveMap($sourceMap); + break; + } + + $out .= sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl); + } + + return $out; + } + + /** + * Instantiate parser + * + * @param string $path + * + * @return \Leafo\ScssPhp\Parser + */ + protected function parserFactory($path) + { + $parser = new Parser($path, count($this->sourceNames), $this->encoding); + + $this->sourceNames[] = $path; + $this->addParsedFile($path); + + return $parser; + } + + /** + * Is self extend? + * + * @param array $target + * @param array $origin + * + * @return boolean + */ + protected function isSelfExtend($target, $origin) + { + foreach ($origin as $sel) { + if (in_array($target, $sel)) { + return true; + } + } + + return false; + } + + /** + * Push extends + * + * @param array $target + * @param array $origin + * @param \stdClass $block + */ + protected function pushExtends($target, $origin, $block) + { + if ($this->isSelfExtend($target, $origin)) { + return; + } + + $i = count($this->extends); + $this->extends[] = [$target, $origin, $block]; + + foreach ($target as $part) { + if (isset($this->extendsMap[$part])) { + $this->extendsMap[$part][] = $i; + } else { + $this->extendsMap[$part] = [$i]; + } + } + } + + /** + * Make output block + * + * @param string $type + * @param array $selectors + * + * @return \Leafo\ScssPhp\Formatter\OutputBlock + */ + protected function makeOutputBlock($type, $selectors = null) + { + $out = new OutputBlock; + $out->type = $type; + $out->lines = []; + $out->children = []; + $out->parent = $this->scope; + $out->selectors = $selectors; + $out->depth = $this->env->depth; + $out->sourceName = $this->env->block->sourceName; + $out->sourceLine = $this->env->block->sourceLine; + $out->sourceColumn = $this->env->block->sourceColumn; + + return $out; + } + + /** + * Compile root + * + * @param \Leafo\ScssPhp\Block $rootBlock + */ + protected function compileRoot(Block $rootBlock) + { + $this->rootBlock = $this->scope = $this->makeOutputBlock(Type::T_ROOT); + + $this->compileChildrenNoReturn($rootBlock->children, $this->scope); + $this->flattenSelectors($this->scope); + $this->missingSelectors(); + } + + /** + * Report missing selectors + */ + protected function missingSelectors() + { + foreach ($this->extends as $extend) { + if (isset($extend[3])) { + continue; + } + + list($target, $origin, $block) = $extend; + + // ignore if !optional + if ($block[2]) { + continue; + } + + $target = implode(' ', $target); + $origin = $this->collapseSelectors($origin); + + $this->sourceLine = $block[Parser::SOURCE_LINE]; + $this->throwError("\"$origin\" failed to @extend \"$target\". The selector \"$target\" was not found."); + } + } + + /** + * Flatten selectors + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param string $parentKey + */ + protected function flattenSelectors(OutputBlock $block, $parentKey = null) + { + if ($block->selectors) { + $selectors = []; + + foreach ($block->selectors as $s) { + $selectors[] = $s; + + if (! is_array($s)) { + continue; + } + + // check extends + if (! empty($this->extendsMap)) { + $this->matchExtends($s, $selectors); + + // remove duplicates + array_walk($selectors, function (&$value) { + $value = serialize($value); + }); + + $selectors = array_unique($selectors); + + array_walk($selectors, function (&$value) { + $value = unserialize($value); + }); + } + } + + $block->selectors = []; + $placeholderSelector = false; + + foreach ($selectors as $selector) { + if ($this->hasSelectorPlaceholder($selector)) { + $placeholderSelector = true; + continue; + } + + $block->selectors[] = $this->compileSelector($selector); + } + + if ($placeholderSelector && 0 === count($block->selectors) && null !== $parentKey) { + unset($block->parent->children[$parentKey]); + + return; + } + } + + foreach ($block->children as $key => $child) { + $this->flattenSelectors($child, $key); + } + } + + /** + * Match extends + * + * @param array $selector + * @param array $out + * @param integer $from + * @param boolean $initial + */ + protected function matchExtends($selector, &$out, $from = 0, $initial = true) + { + foreach ($selector as $i => $part) { + if ($i < $from) { + continue; + } + + if ($this->matchExtendsSingle($part, $origin)) { + $after = array_slice($selector, $i + 1); + $before = array_slice($selector, 0, $i); + + list($before, $nonBreakableBefore) = $this->extractRelationshipFromFragment($before); + + foreach ($origin as $new) { + $k = 0; + + // remove shared parts + if ($initial) { + while ($k < $i && isset($new[$k]) && $selector[$k] === $new[$k]) { + $k++; + } + } + + $replacement = []; + $tempReplacement = $k > 0 ? array_slice($new, $k) : $new; + + for ($l = count($tempReplacement) - 1; $l >= 0; $l--) { + $slice = $tempReplacement[$l]; + array_unshift($replacement, $slice); + + if (! $this->isImmediateRelationshipCombinator(end($slice))) { + break; + } + } + + $afterBefore = $l != 0 ? array_slice($tempReplacement, 0, $l) : []; + + // Merge shared direct relationships. + $mergedBefore = $this->mergeDirectRelationships($afterBefore, $nonBreakableBefore); + + $result = array_merge( + $before, + $mergedBefore, + $replacement, + $after + ); + + if ($result === $selector) { + continue; + } + + $out[] = $result; + + // recursively check for more matches + $this->matchExtends($result, $out, count($before) + count($mergedBefore), false); + + // selector sequence merging + if (! empty($before) && count($new) > 1) { + $sharedParts = $k > 0 ? array_slice($before, 0, $k) : []; + $postSharedParts = $k > 0 ? array_slice($before, $k) : $before; + + list($injectBetweenSharedParts, $nonBreakable2) = $this->extractRelationshipFromFragment($afterBefore); + + $result2 = array_merge( + $sharedParts, + $injectBetweenSharedParts, + $postSharedParts, + $nonBreakable2, + $nonBreakableBefore, + $replacement, + $after + ); + + $out[] = $result2; + } + } + } + } + } + + /** + * Match extends single + * + * @param array $rawSingle + * @param array $outOrigin + * + * @return boolean + */ + protected function matchExtendsSingle($rawSingle, &$outOrigin) + { + $counts = []; + $single = []; + + foreach ($rawSingle as $part) { + // matches Number + if (! is_string($part)) { + return false; + } + + if (! preg_match('/^[\[.:#%]/', $part) && count($single)) { + $single[count($single) - 1] .= $part; + } else { + $single[] = $part; + } + } + + $extendingDecoratedTag = false; + + if (count($single) > 1) { + $matches = null; + $extendingDecoratedTag = preg_match('/^[a-z0-9]+$/i', $single[0], $matches) ? $matches[0] : false; + } + + foreach ($single as $part) { + if (isset($this->extendsMap[$part])) { + foreach ($this->extendsMap[$part] as $idx) { + $counts[$idx] = isset($counts[$idx]) ? $counts[$idx] + 1 : 1; + } + } + } + + $outOrigin = []; + $found = false; + + foreach ($counts as $idx => $count) { + list($target, $origin, /* $block */) = $this->extends[$idx]; + + // check count + if ($count !== count($target)) { + continue; + } + + $this->extends[$idx][3] = true; + + $rem = array_diff($single, $target); + + foreach ($origin as $j => $new) { + // prevent infinite loop when target extends itself + if ($this->isSelfExtend($single, $origin)) { + return false; + } + + $replacement = end($new); + + // Extending a decorated tag with another tag is not possible. + if ($extendingDecoratedTag && $replacement[0] != $extendingDecoratedTag && + preg_match('/^[a-z0-9]+$/i', $replacement[0]) + ) { + unset($origin[$j]); + continue; + } + + $combined = $this->combineSelectorSingle($replacement, $rem); + + if (count(array_diff($combined, $origin[$j][count($origin[$j]) - 1]))) { + $origin[$j][count($origin[$j]) - 1] = $combined; + } + } + + $outOrigin = array_merge($outOrigin, $origin); + + $found = true; + } + + return $found; + } + + + /** + * Extract a relationship from the fragment. + * + * When extracting the last portion of a selector we will be left with a + * fragment which may end with a direction relationship combinator. This + * method will extract the relationship fragment and return it along side + * the rest. + * + * @param array $fragment The selector fragment maybe ending with a direction relationship combinator. + * @return array The selector without the relationship fragment if any, the relationship fragment. + */ + protected function extractRelationshipFromFragment(array $fragment) + { + $parents = []; + $children = []; + $j = $i = count($fragment); + + for (;;) { + $children = $j != $i ? array_slice($fragment, $j, $i - $j) : []; + $parents = array_slice($fragment, 0, $j); + $slice = end($parents); + + if (empty($slice) || ! $this->isImmediateRelationshipCombinator($slice[0])) { + break; + } + + $j -= 2; + } + + return [$parents, $children]; + } + + /** + * Combine selector single + * + * @param array $base + * @param array $other + * + * @return array + */ + protected function combineSelectorSingle($base, $other) + { + $tag = []; + $out = []; + $wasTag = true; + + foreach ([$base, $other] as $single) { + foreach ($single as $part) { + if (preg_match('/^[\[.:#]/', $part)) { + $out[] = $part; + $wasTag = false; + } elseif (preg_match('/^[^_-]/', $part)) { + $tag[] = $part; + $wasTag = true; + } elseif ($wasTag) { + $tag[count($tag) - 1] .= $part; + } else { + $out[count($out) - 1] .= $part; + } + } + } + + if (count($tag)) { + array_unshift($out, $tag[0]); + } + + return $out; + } + + /** + * Compile media + * + * @param \Leafo\ScssPhp\Block $media + */ + protected function compileMedia(Block $media) + { + $this->pushEnv($media); + + $mediaQuery = $this->compileMediaQuery($this->multiplyMedia($this->env)); + + if (! empty($mediaQuery)) { + $this->scope = $this->makeOutputBlock(Type::T_MEDIA, [$mediaQuery]); + + $parentScope = $this->mediaParent($this->scope); + $parentScope->children[] = $this->scope; + + // top level properties in a media cause it to be wrapped + $needsWrap = false; + + foreach ($media->children as $child) { + $type = $child[0]; + + if ($type !== Type::T_BLOCK && + $type !== Type::T_MEDIA && + $type !== Type::T_DIRECTIVE && + $type !== Type::T_IMPORT + ) { + $needsWrap = true; + break; + } + } + + if ($needsWrap) { + $wrapped = new Block; + $wrapped->sourceName = $media->sourceName; + $wrapped->sourceIndex = $media->sourceIndex; + $wrapped->sourceLine = $media->sourceLine; + $wrapped->sourceColumn = $media->sourceColumn; + $wrapped->selectors = []; + $wrapped->comments = []; + $wrapped->parent = $media; + $wrapped->children = $media->children; + + $media->children = [[Type::T_BLOCK, $wrapped]]; + } + + $this->compileChildrenNoReturn($media->children, $this->scope); + + $this->scope = $this->scope->parent; + } + + $this->popEnv(); + } + + /** + * Media parent + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope + * + * @return \Leafo\ScssPhp\Formatter\OutputBlock + */ + protected function mediaParent(OutputBlock $scope) + { + while (! empty($scope->parent)) { + if (! empty($scope->type) && $scope->type !== Type::T_MEDIA) { + break; + } + + $scope = $scope->parent; + } + + return $scope; + } + + /** + * Compile directive + * + * @param \Leafo\ScssPhp\Block $block + */ + protected function compileDirective(Block $block) + { + $s = '@' . $block->name; + + if (! empty($block->value)) { + $s .= ' ' . $this->compileValue($block->value); + } + + if ($block->name === 'keyframes' || substr($block->name, -10) === '-keyframes') { + $this->compileKeyframeBlock($block, [$s]); + } else { + $this->compileNestedBlock($block, [$s]); + } + } + + /** + * Compile at-root + * + * @param \Leafo\ScssPhp\Block $block + */ + protected function compileAtRoot(Block $block) + { + $env = $this->pushEnv($block); + $envs = $this->compactEnv($env); + $without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE; + + // wrap inline selector + if ($block->selector) { + $wrapped = new Block; + $wrapped->sourceName = $block->sourceName; + $wrapped->sourceIndex = $block->sourceIndex; + $wrapped->sourceLine = $block->sourceLine; + $wrapped->sourceColumn = $block->sourceColumn; + $wrapped->selectors = $block->selector; + $wrapped->comments = []; + $wrapped->parent = $block; + $wrapped->children = $block->children; + + $block->children = [[Type::T_BLOCK, $wrapped]]; + } + + $this->env = $this->filterWithout($envs, $without); + $newBlock = $this->spliceTree($envs, $block, $without); + + $saveScope = $this->scope; + $this->scope = $this->rootBlock; + + $this->compileChild($newBlock, $this->scope); + + $this->scope = $saveScope; + $this->env = $this->extractEnv($envs); + + $this->popEnv(); + } + + /** + * Splice parse tree + * + * @param array $envs + * @param \Leafo\ScssPhp\Block $block + * @param integer $without + * + * @return array + */ + private function spliceTree($envs, Block $block, $without) + { + $newBlock = null; + + foreach ($envs as $e) { + if (! isset($e->block)) { + continue; + } + + if ($e->block === $block) { + continue; + } + + if (isset($e->block->type) && $e->block->type === Type::T_AT_ROOT) { + continue; + } + + if ($e->block && $this->isWithout($without, $e->block)) { + continue; + } + + $b = new Block; + $b->sourceName = $e->block->sourceName; + $b->sourceIndex = $e->block->sourceIndex; + $b->sourceLine = $e->block->sourceLine; + $b->sourceColumn = $e->block->sourceColumn; + $b->selectors = []; + $b->comments = $e->block->comments; + $b->parent = null; + + if ($newBlock) { + $type = isset($newBlock->type) ? $newBlock->type : Type::T_BLOCK; + + $b->children = [[$type, $newBlock]]; + + $newBlock->parent = $b; + } elseif (count($block->children)) { + foreach ($block->children as $child) { + if ($child[0] === Type::T_BLOCK) { + $child[1]->parent = $b; + } + } + + $b->children = $block->children; + } + + if (isset($e->block->type)) { + $b->type = $e->block->type; + } + + if (isset($e->block->name)) { + $b->name = $e->block->name; + } + + if (isset($e->block->queryList)) { + $b->queryList = $e->block->queryList; + } + + if (isset($e->block->value)) { + $b->value = $e->block->value; + } + + $newBlock = $b; + } + + $type = isset($newBlock->type) ? $newBlock->type : Type::T_BLOCK; + + return [$type, $newBlock]; + } + + /** + * Compile @at-root's with: inclusion / without: exclusion into filter flags + * + * @param array $with + * + * @return integer + */ + private function compileWith($with) + { + static $mapping = [ + 'rule' => self::WITH_RULE, + 'media' => self::WITH_MEDIA, + 'supports' => self::WITH_SUPPORTS, + 'all' => self::WITH_ALL, + ]; + + // exclude selectors by default + $without = static::WITH_RULE; + + if ($this->libMapHasKey([$with, static::$with])) { + $without = static::WITH_ALL; + + $list = $this->coerceList($this->libMapGet([$with, static::$with])); + + foreach ($list[2] as $item) { + $keyword = $this->compileStringContent($this->coerceString($item)); + + if (array_key_exists($keyword, $mapping)) { + $without &= ~($mapping[$keyword]); + } + } + } + + if ($this->libMapHasKey([$with, static::$without])) { + $without = 0; + + $list = $this->coerceList($this->libMapGet([$with, static::$without])); + + foreach ($list[2] as $item) { + $keyword = $this->compileStringContent($this->coerceString($item)); + + if (array_key_exists($keyword, $mapping)) { + $without |= $mapping[$keyword]; + } + } + } + + return $without; + } + + /** + * Filter env stack + * + * @param array $envs + * @param integer $without + * + * @return \Leafo\ScssPhp\Compiler\Environment + */ + private function filterWithout($envs, $without) + { + $filtered = []; + + foreach ($envs as $e) { + if ($e->block && $this->isWithout($without, $e->block)) { + continue; + } + + $filtered[] = $e; + } + + return $this->extractEnv($filtered); + } + + /** + * Filter WITH rules + * + * @param integer $without + * @param \Leafo\ScssPhp\Block $block + * + * @return boolean + */ + private function isWithout($without, Block $block) + { + if ((($without & static::WITH_RULE) && isset($block->selectors)) || + (($without & static::WITH_MEDIA) && + isset($block->type) && $block->type === Type::T_MEDIA) || + (($without & static::WITH_SUPPORTS) && + isset($block->type) && $block->type === Type::T_DIRECTIVE && + isset($block->name) && $block->name === 'supports') + ) { + return true; + } + + return false; + } + + /** + * Compile keyframe block + * + * @param \Leafo\ScssPhp\Block $block + * @param array $selectors + */ + protected function compileKeyframeBlock(Block $block, $selectors) + { + $env = $this->pushEnv($block); + + $envs = $this->compactEnv($env); + + $this->env = $this->extractEnv(array_filter($envs, function (Environment $e) { + return ! isset($e->block->selectors); + })); + + $this->scope = $this->makeOutputBlock($block->type, $selectors); + $this->scope->depth = 1; + $this->scope->parent->children[] = $this->scope; + + $this->compileChildrenNoReturn($block->children, $this->scope); + + $this->scope = $this->scope->parent; + $this->env = $this->extractEnv($envs); + + $this->popEnv(); + } + + /** + * Compile nested block + * + * @param \Leafo\ScssPhp\Block $block + * @param array $selectors + */ + protected function compileNestedBlock(Block $block, $selectors) + { + $this->pushEnv($block); + + $this->scope = $this->makeOutputBlock($block->type, $selectors); + $this->scope->parent->children[] = $this->scope; + + $this->compileChildrenNoReturn($block->children, $this->scope); + + $this->scope = $this->scope->parent; + + $this->popEnv(); + } + + /** + * Recursively compiles a block. + * + * A block is analogous to a CSS block in most cases. A single SCSS document + * is encapsulated in a block when parsed, but it does not have parent tags + * so all of its children appear on the root level when compiled. + * + * Blocks are made up of selectors and children. + * + * The children of a block are just all the blocks that are defined within. + * + * Compiling the block involves pushing a fresh environment on the stack, + * and iterating through the props, compiling each one. + * + * @see Compiler::compileChild() + * + * @param \Leafo\ScssPhp\Block $block + */ + protected function compileBlock(Block $block) + { + $env = $this->pushEnv($block); + $env->selectors = $this->evalSelectors($block->selectors); + + $out = $this->makeOutputBlock(null); + + if (isset($this->lineNumberStyle) && count($env->selectors) && count($block->children)) { + $annotation = $this->makeOutputBlock(Type::T_COMMENT); + $annotation->depth = 0; + + $file = $this->sourceNames[$block->sourceIndex]; + $line = $block->sourceLine; + + switch ($this->lineNumberStyle) { + case static::LINE_COMMENTS: + $annotation->lines[] = '/* line ' . $line + . ($file ? ', ' . $file : '') + . ' */'; + break; + + case static::DEBUG_INFO: + $annotation->lines[] = '@media -sass-debug-info{' + . ($file ? 'filename{font-family:"' . $file . '"}' : '') + . 'line{font-family:' . $line . '}}'; + break; + } + + $this->scope->children[] = $annotation; + } + + $this->scope->children[] = $out; + + if (count($block->children)) { + $out->selectors = $this->multiplySelectors($env); + + $this->compileChildrenNoReturn($block->children, $out); + } + + $this->formatter->stripSemicolon($out->lines); + + $this->popEnv(); + } + + /** + * Compile root level comment + * + * @param array $block + */ + protected function compileComment($block) + { + $out = $this->makeOutputBlock(Type::T_COMMENT); + $out->lines[] = $block[1]; + $this->scope->children[] = $out; + } + + /** + * Evaluate selectors + * + * @param array $selectors + * + * @return array + */ + protected function evalSelectors($selectors) + { + $this->shouldEvaluate = false; + + $selectors = array_map([$this, 'evalSelector'], $selectors); + + // after evaluating interpolates, we might need a second pass + if ($this->shouldEvaluate) { + $buffer = $this->collapseSelectors($selectors); + $parser = $this->parserFactory(__METHOD__); + + if ($parser->parseSelector($buffer, $newSelectors)) { + $selectors = array_map([$this, 'evalSelector'], $newSelectors); + } + } + + return $selectors; + } + + /** + * Evaluate selector + * + * @param array $selector + * + * @return array + */ + protected function evalSelector($selector) + { + return array_map([$this, 'evalSelectorPart'], $selector); + } + + /** + * Evaluate selector part; replaces all the interpolates, stripping quotes + * + * @param array $part + * + * @return array + */ + protected function evalSelectorPart($part) + { + foreach ($part as &$p) { + if (is_array($p) && ($p[0] === Type::T_INTERPOLATE || $p[0] === Type::T_STRING)) { + $p = $this->compileValue($p); + + // force re-evaluation + if (strpos($p, '&') !== false || strpos($p, ',') !== false) { + $this->shouldEvaluate = true; + } + } elseif (is_string($p) && strlen($p) >= 2 && + ($first = $p[0]) && ($first === '"' || $first === "'") && + substr($p, -1) === $first + ) { + $p = substr($p, 1, -1); + } + } + + return $this->flattenSelectorSingle($part); + } + + /** + * Collapse selectors + * + * @param array $selectors + * + * @return string + */ + protected function collapseSelectors($selectors) + { + $parts = []; + + foreach ($selectors as $selector) { + $output = ''; + + array_walk_recursive( + $selector, + function ($value, $key) use (&$output) { + $output .= $value; + } + ); + + $parts[] = $output; + } + + return implode(', ', $parts); + } + + /** + * Flatten selector single; joins together .classes and #ids + * + * @param array $single + * + * @return array + */ + protected function flattenSelectorSingle($single) + { + $joined = []; + + foreach ($single as $part) { + if (empty($joined) || + ! is_string($part) || + preg_match('/[\[.:#%]/', $part) + ) { + $joined[] = $part; + continue; + } + + if (is_array(end($joined))) { + $joined[] = $part; + } else { + $joined[count($joined) - 1] .= $part; + } + } + + return $joined; + } + + /** + * Compile selector to string; self(&) should have been replaced by now + * + * @param string|array $selector + * + * @return string + */ + protected function compileSelector($selector) + { + if (! is_array($selector)) { + return $selector; // media and the like + } + + return implode( + ' ', + array_map( + [$this, 'compileSelectorPart'], + $selector + ) + ); + } + + /** + * Compile selector part + * + * @param array $piece + * + * @return string + */ + protected function compileSelectorPart($piece) + { + foreach ($piece as &$p) { + if (! is_array($p)) { + continue; + } + + switch ($p[0]) { + case Type::T_SELF: + $p = '&'; + break; + + default: + $p = $this->compileValue($p); + break; + } + } + + return implode($piece); + } + + /** + * Has selector placeholder? + * + * @param array $selector + * + * @return boolean + */ + protected function hasSelectorPlaceholder($selector) + { + if (! is_array($selector)) { + return false; + } + + foreach ($selector as $parts) { + foreach ($parts as $part) { + if (strlen($part) && '%' === $part[0]) { + return true; + } + } + } + + return false; + } + + /** + * Compile children and return result + * + * @param array $stms + * @param \Leafo\ScssPhp\Formatter\OutputBlock $out + * + * @return array + */ + protected function compileChildren($stms, OutputBlock $out) + { + foreach ($stms as $stm) { + $ret = $this->compileChild($stm, $out); + + if (isset($ret)) { + return $ret; + } + } + } + + /** + * Compile children and throw exception if unexpected @return + * + * @param array $stms + * @param \Leafo\ScssPhp\Formatter\OutputBlock $out + * + * @throws \Exception + */ + protected function compileChildrenNoReturn($stms, OutputBlock $out) + { + foreach ($stms as $stm) { + $ret = $this->compileChild($stm, $out); + + if (isset($ret)) { + $this->throwError('@return may only be used within a function'); + + return; + } + } + } + + /** + * Compile media query + * + * @param array $queryList + * + * @return string + */ + protected function compileMediaQuery($queryList) + { + $out = '@media'; + $first = true; + + foreach ($queryList as $query) { + $type = null; + $parts = []; + + foreach ($query as $q) { + switch ($q[0]) { + case Type::T_MEDIA_TYPE: + if ($type) { + $type = $this->mergeMediaTypes( + $type, + array_map([$this, 'compileValue'], array_slice($q, 1)) + ); + + if (empty($type)) { // merge failed + return null; + } + } else { + $type = array_map([$this, 'compileValue'], array_slice($q, 1)); + } + break; + + case Type::T_MEDIA_EXPRESSION: + if (isset($q[2])) { + $parts[] = '(' + . $this->compileValue($q[1]) + . $this->formatter->assignSeparator + . $this->compileValue($q[2]) + . ')'; + } else { + $parts[] = '(' + . $this->compileValue($q[1]) + . ')'; + } + break; + + case Type::T_MEDIA_VALUE: + $parts[] = $this->compileValue($q[1]); + break; + } + } + + if ($type) { + array_unshift($parts, implode(' ', array_filter($type))); + } + + if (! empty($parts)) { + if ($first) { + $first = false; + $out .= ' '; + } else { + $out .= $this->formatter->tagSeparator; + } + + $out .= implode(' and ', $parts); + } + } + + return $out; + } + + protected function mergeDirectRelationships($selectors1, $selectors2) + { + if (empty($selectors1) || empty($selectors2)) { + return array_merge($selectors1, $selectors2); + } + + $part1 = end($selectors1); + $part2 = end($selectors2); + + if (! $this->isImmediateRelationshipCombinator($part1[0]) || $part1 !== $part2) { + return array_merge($selectors1, $selectors2); + } + + $merged = []; + + do { + $part1 = array_pop($selectors1); + $part2 = array_pop($selectors2); + + if ($this->isImmediateRelationshipCombinator($part1[0]) && $part1 !== $part2) { + $merged = array_merge($selectors1, [$part1], $selectors2, [$part2], $merged); + break; + } + + array_unshift($merged, $part1); + array_unshift($merged, [array_pop($selectors1)[0] . array_pop($selectors2)[0]]); + } while (! empty($selectors1) && ! empty($selectors2)); + + return $merged; + } + + /** + * Merge media types + * + * @param array $type1 + * @param array $type2 + * + * @return array|null + */ + protected function mergeMediaTypes($type1, $type2) + { + if (empty($type1)) { + return $type2; + } + + if (empty($type2)) { + return $type1; + } + + $m1 = ''; + $t1 = ''; + + if (count($type1) > 1) { + $m1= strtolower($type1[0]); + $t1= strtolower($type1[1]); + } else { + $t1 = strtolower($type1[0]); + } + + $m2 = ''; + $t2 = ''; + + if (count($type2) > 1) { + $m2 = strtolower($type2[0]); + $t2 = strtolower($type2[1]); + } else { + $t2 = strtolower($type2[0]); + } + + if (($m1 === Type::T_NOT) ^ ($m2 === Type::T_NOT)) { + if ($t1 === $t2) { + return null; + } + + return [ + $m1 === Type::T_NOT ? $m2 : $m1, + $m1 === Type::T_NOT ? $t2 : $t1, + ]; + } + + if ($m1 === Type::T_NOT && $m2 === Type::T_NOT) { + // CSS has no way of representing "neither screen nor print" + if ($t1 !== $t2) { + return null; + } + + return [Type::T_NOT, $t1]; + } + + if ($t1 !== $t2) { + return null; + } + + // t1 == t2, neither m1 nor m2 are "not" + return [empty($m1)? $m2 : $m1, $t1]; + } + + /** + * Compile import; returns true if the value was something that could be imported + * + * @param array $rawPath + * @param array $out + * @param boolean $once + * + * @return boolean + */ + protected function compileImport($rawPath, $out, $once = false) + { + if ($rawPath[0] === Type::T_STRING) { + $path = $this->compileStringContent($rawPath); + + if ($path = $this->findImport($path)) { + if (! $once || ! in_array($path, $this->importedFiles)) { + $this->importFile($path, $out); + $this->importedFiles[] = $path; + } + + return true; + } + + return false; + } + + if ($rawPath[0] === Type::T_LIST) { + // handle a list of strings + if (count($rawPath[2]) === 0) { + return false; + } + + foreach ($rawPath[2] as $path) { + if ($path[0] !== Type::T_STRING) { + return false; + } + } + + foreach ($rawPath[2] as $path) { + $this->compileImport($path, $out); + } + + return true; + } + + return false; + } + + /** + * Compile child; returns a value to halt execution + * + * @param array $child + * @param \Leafo\ScssPhp\Formatter\OutputBlock $out + * + * @return array + */ + protected function compileChild($child, OutputBlock $out) + { + $this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null; + $this->sourceLine = isset($child[Parser::SOURCE_LINE]) ? $child[Parser::SOURCE_LINE] : -1; + $this->sourceColumn = isset($child[Parser::SOURCE_COLUMN]) ? $child[Parser::SOURCE_COLUMN] : -1; + + switch ($child[0]) { + case Type::T_SCSSPHP_IMPORT_ONCE: + list(, $rawPath) = $child; + + $rawPath = $this->reduce($rawPath); + + if (! $this->compileImport($rawPath, $out, true)) { + $out->lines[] = '@import ' . $this->compileValue($rawPath) . ';'; + } + break; + + case Type::T_IMPORT: + list(, $rawPath) = $child; + + $rawPath = $this->reduce($rawPath); + + if (! $this->compileImport($rawPath, $out)) { + $out->lines[] = '@import ' . $this->compileValue($rawPath) . ';'; + } + break; + + case Type::T_DIRECTIVE: + $this->compileDirective($child[1]); + break; + + case Type::T_AT_ROOT: + $this->compileAtRoot($child[1]); + break; + + case Type::T_MEDIA: + $this->compileMedia($child[1]); + break; + + case Type::T_BLOCK: + $this->compileBlock($child[1]); + break; + + case Type::T_CHARSET: + if (! $this->charsetSeen) { + $this->charsetSeen = true; + + $out->lines[] = '@charset ' . $this->compileValue($child[1]) . ';'; + } + break; + + case Type::T_ASSIGN: + list(, $name, $value) = $child; + + if ($name[0] === Type::T_VARIABLE) { + $flags = isset($child[3]) ? $child[3] : []; + $isDefault = in_array('!default', $flags); + $isGlobal = in_array('!global', $flags); + + if ($isGlobal) { + $this->set($name[1], $this->reduce($value), false, $this->rootEnv); + break; + } + + $shouldSet = $isDefault && + (($result = $this->get($name[1], false)) === null + || $result === static::$null); + + if (! $isDefault || $shouldSet) { + $this->set($name[1], $this->reduce($value)); + } + break; + } + + $compiledName = $this->compileValue($name); + + // handle shorthand syntax: size / line-height + if ($compiledName === 'font') { + if ($value[0] === Type::T_EXPRESSION && $value[1] === '/') { + $value = $this->expToString($value); + } elseif ($value[0] === Type::T_LIST) { + foreach ($value[2] as &$item) { + if ($item[0] === Type::T_EXPRESSION && $item[1] === '/') { + $item = $this->expToString($item); + } + } + } + } + + // if the value reduces to null from something else then + // the property should be discarded + if ($value[0] !== Type::T_NULL) { + $value = $this->reduce($value); + + if ($value[0] === Type::T_NULL || $value === static::$nullString) { + break; + } + } + + $compiledValue = $this->compileValue($value); + + $out->lines[] = $this->formatter->property( + $compiledName, + $compiledValue + ); + break; + + case Type::T_COMMENT: + if ($out->type === Type::T_ROOT) { + $this->compileComment($child); + break; + } + + $out->lines[] = $child[1]; + break; + + case Type::T_MIXIN: + case Type::T_FUNCTION: + list(, $block) = $child; + + $this->set(static::$namespaces[$block->type] . $block->name, $block); + break; + + case Type::T_EXTEND: + list(, $selectors) = $child; + + foreach ($selectors as $sel) { + $results = $this->evalSelectors([$sel]); + + foreach ($results as $result) { + // only use the first one + $result = current($result); + + $this->pushExtends($result, $out->selectors, $child); + } + } + break; + + case Type::T_IF: + list(, $if) = $child; + + if ($this->isTruthy($this->reduce($if->cond, true))) { + return $this->compileChildren($if->children, $out); + } + + foreach ($if->cases as $case) { + if ($case->type === Type::T_ELSE || + $case->type === Type::T_ELSEIF && $this->isTruthy($this->reduce($case->cond)) + ) { + return $this->compileChildren($case->children, $out); + } + } + break; + + case Type::T_EACH: + list(, $each) = $child; + + $list = $this->coerceList($this->reduce($each->list)); + + $this->pushEnv(); + + foreach ($list[2] as $item) { + if (count($each->vars) === 1) { + $this->set($each->vars[0], $item, true); + } else { + list(,, $values) = $this->coerceList($item); + + foreach ($each->vars as $i => $var) { + $this->set($var, isset($values[$i]) ? $values[$i] : static::$null, true); + } + } + + $ret = $this->compileChildren($each->children, $out); + + if ($ret) { + if ($ret[0] !== Type::T_CONTROL) { + $this->popEnv(); + + return $ret; + } + + if ($ret[1]) { + break; + } + } + } + + $this->popEnv(); + break; + + case Type::T_WHILE: + list(, $while) = $child; + + while ($this->isTruthy($this->reduce($while->cond, true))) { + $ret = $this->compileChildren($while->children, $out); + + if ($ret) { + if ($ret[0] !== Type::T_CONTROL) { + return $ret; + } + + if ($ret[1]) { + break; + } + } + } + break; + + case Type::T_FOR: + list(, $for) = $child; + + $start = $this->reduce($for->start, true); + $end = $this->reduce($for->end, true); + + if (! ($start[2] == $end[2] || $end->unitless())) { + $this->throwError('Incompatible units: "%s" and "%s".', $start->unitStr(), $end->unitStr()); + + break; + } + + $unit = $start[2]; + $start = $start[1]; + $end = $end[1]; + + $d = $start < $end ? 1 : -1; + + for (;;) { + if ((! $for->until && $start - $d == $end) || + ($for->until && $start == $end) + ) { + break; + } + + $this->set($for->var, new Node\Number($start, $unit)); + $start += $d; + + $ret = $this->compileChildren($for->children, $out); + + if ($ret) { + if ($ret[0] !== Type::T_CONTROL) { + return $ret; + } + + if ($ret[1]) { + break; + } + } + } + break; + + case Type::T_BREAK: + return [Type::T_CONTROL, true]; + + case Type::T_CONTINUE: + return [Type::T_CONTROL, false]; + + case Type::T_RETURN: + return $this->reduce($child[1], true); + + case Type::T_NESTED_PROPERTY: + list(, $prop) = $child; + + $prefixed = []; + $prefix = $this->compileValue($prop->prefix) . '-'; + + foreach ($prop->children as $child) { + switch ($child[0]) { + case Type::T_ASSIGN: + array_unshift($child[1][2], $prefix); + break; + + case Type::T_NESTED_PROPERTY: + array_unshift($child[1]->prefix[2], $prefix); + break; + } + + $prefixed[] = $child; + } + + $this->compileChildrenNoReturn($prefixed, $out); + break; + + case Type::T_INCLUDE: + // including a mixin + list(, $name, $argValues, $content) = $child; + + $mixin = $this->get(static::$namespaces['mixin'] . $name, false); + + if (! $mixin) { + $this->throwError("Undefined mixin $name"); + break; + } + + $callingScope = $this->getStoreEnv(); + + // push scope, apply args + $this->pushEnv(); + $this->env->depth--; + + $storeEnv = $this->storeEnv; + $this->storeEnv = $this->env; + + if (isset($content)) { + $content->scope = $callingScope; + + $this->setRaw(static::$namespaces['special'] . 'content', $content, $this->env); + } + + if (isset($mixin->args)) { + $this->applyArguments($mixin->args, $argValues); + } + + $this->env->marker = 'mixin'; + + $this->compileChildrenNoReturn($mixin->children, $out); + + $this->storeEnv = $storeEnv; + + $this->popEnv(); + break; + + case Type::T_MIXIN_CONTENT: + $content = $this->get(static::$namespaces['special'] . 'content', false, $this->getStoreEnv()) + ?: $this->get(static::$namespaces['special'] . 'content', false, $this->env); + + if (! $content) { + $content = new \stdClass(); + $content->scope = new \stdClass(); + $content->children = $this->storeEnv->parent->block->children; + break; + } + + $storeEnv = $this->storeEnv; + $this->storeEnv = $content->scope; + + $this->compileChildrenNoReturn($content->children, $out); + + $this->storeEnv = $storeEnv; + break; + + case Type::T_DEBUG: + list(, $value) = $child; + + $line = $this->sourceLine; + $value = $this->compileValue($this->reduce($value, true)); + fwrite($this->stderr, "Line $line DEBUG: $value\n"); + break; + + case Type::T_WARN: + list(, $value) = $child; + + $line = $this->sourceLine; + $value = $this->compileValue($this->reduce($value, true)); + fwrite($this->stderr, "Line $line WARN: $value\n"); + break; + + case Type::T_ERROR: + list(, $value) = $child; + + $line = $this->sourceLine; + $value = $this->compileValue($this->reduce($value, true)); + $this->throwError("Line $line ERROR: $value\n"); + break; + + case Type::T_CONTROL: + $this->throwError('@break/@continue not permitted in this scope'); + break; + + default: + $this->throwError("unknown child type: $child[0]"); + } + } + + /** + * Reduce expression to string + * + * @param array $exp + * + * @return array + */ + protected function expToString($exp) + { + list(, $op, $left, $right, /* $inParens */, $whiteLeft, $whiteRight) = $exp; + + $content = [$this->reduce($left)]; + + if ($whiteLeft) { + $content[] = ' '; + } + + $content[] = $op; + + if ($whiteRight) { + $content[] = ' '; + } + + $content[] = $this->reduce($right); + + return [Type::T_STRING, '', $content]; + } + + /** + * Is truthy? + * + * @param array $value + * + * @return array + */ + protected function isTruthy($value) + { + return $value !== static::$false && $value !== static::$null; + } + + /** + * Is the value a direct relationship combinator? + * + * @param string $value + * + * @return boolean + */ + protected function isImmediateRelationshipCombinator($value) + { + return $value === '>' || $value === '+' || $value === '~'; + } + + /** + * Should $value cause its operand to eval + * + * @param array $value + * + * @return boolean + */ + protected function shouldEval($value) + { + switch ($value[0]) { + case Type::T_EXPRESSION: + if ($value[1] === '/') { + return $this->shouldEval($value[2], $value[3]); + } + + // fall-thru + case Type::T_VARIABLE: + case Type::T_FUNCTION_CALL: + return true; + } + + return false; + } + + /** + * Reduce value + * + * @param array $value + * @param boolean $inExp + * + * @return array|\Leafo\ScssPhp\Node\Number + */ + protected function reduce($value, $inExp = false) + { + list($type) = $value; + + switch ($type) { + case Type::T_EXPRESSION: + list(, $op, $left, $right, $inParens) = $value; + + $opName = isset(static::$operatorNames[$op]) ? static::$operatorNames[$op] : $op; + $inExp = $inExp || $this->shouldEval($left) || $this->shouldEval($right); + + $left = $this->reduce($left, true); + + if ($op !== 'and' && $op !== 'or') { + $right = $this->reduce($right, true); + } + + // special case: looks like css shorthand + if ($opName == 'div' && ! $inParens && ! $inExp && isset($right[2]) + && (($right[0] !== Type::T_NUMBER && $right[2] != '') + || ($right[0] === Type::T_NUMBER && ! $right->unitless())) + ) { + return $this->expToString($value); + } + + $left = $this->coerceForExpression($left); + $right = $this->coerceForExpression($right); + + $ltype = $left[0]; + $rtype = $right[0]; + + $ucOpName = ucfirst($opName); + $ucLType = ucfirst($ltype); + $ucRType = ucfirst($rtype); + + // this tries: + // 1. op[op name][left type][right type] + // 2. op[left type][right type] (passing the op as first arg + // 3. op[op name] + $fn = "op${ucOpName}${ucLType}${ucRType}"; + + if (is_callable([$this, $fn]) || + (($fn = "op${ucLType}${ucRType}") && + is_callable([$this, $fn]) && + $passOp = true) || + (($fn = "op${ucOpName}") && + is_callable([$this, $fn]) && + $genOp = true) + ) { + $coerceUnit = false; + + if (! isset($genOp) && + $left[0] === Type::T_NUMBER && $right[0] === Type::T_NUMBER + ) { + $coerceUnit = true; + + switch ($opName) { + case 'mul': + $targetUnit = $left[2]; + + foreach ($right[2] as $unit => $exp) { + $targetUnit[$unit] = (isset($targetUnit[$unit]) ? $targetUnit[$unit] : 0) + $exp; + } + break; + + case 'div': + $targetUnit = $left[2]; + + foreach ($right[2] as $unit => $exp) { + $targetUnit[$unit] = (isset($targetUnit[$unit]) ? $targetUnit[$unit] : 0) - $exp; + } + break; + + case 'mod': + $targetUnit = $left[2]; + break; + + default: + $targetUnit = $left->unitless() ? $right[2] : $left[2]; + } + + if (! $left->unitless() && ! $right->unitless()) { + $left = $left->normalize(); + $right = $right->normalize(); + } + } + + $shouldEval = $inParens || $inExp; + + if (isset($passOp)) { + $out = $this->$fn($op, $left, $right, $shouldEval); + } else { + $out = $this->$fn($left, $right, $shouldEval); + } + + if (isset($out)) { + if ($coerceUnit && $out[0] === Type::T_NUMBER) { + $out = $out->coerce($targetUnit); + } + + return $out; + } + } + + return $this->expToString($value); + + case Type::T_UNARY: + list(, $op, $exp, $inParens) = $value; + + $inExp = $inExp || $this->shouldEval($exp); + $exp = $this->reduce($exp); + + if ($exp[0] === Type::T_NUMBER) { + switch ($op) { + case '+': + return new Node\Number($exp[1], $exp[2]); + + case '-': + return new Node\Number(-$exp[1], $exp[2]); + } + } + + if ($op === 'not') { + if ($inExp || $inParens) { + if ($exp === static::$false || $exp === static::$null) { + return static::$true; + } + + return static::$false; + } + + $op = $op . ' '; + } + + return [Type::T_STRING, '', [$op, $exp]]; + + case Type::T_VARIABLE: + list(, $name) = $value; + + return $this->reduce($this->get($name)); + + case Type::T_LIST: + foreach ($value[2] as &$item) { + $item = $this->reduce($item); + } + + return $value; + + case Type::T_MAP: + foreach ($value[1] as &$item) { + $item = $this->reduce($item); + } + + foreach ($value[2] as &$item) { + $item = $this->reduce($item); + } + + return $value; + + case Type::T_STRING: + foreach ($value[2] as &$item) { + if (is_array($item) || $item instanceof \ArrayAccess) { + $item = $this->reduce($item); + } + } + + return $value; + + case Type::T_INTERPOLATE: + $value[1] = $this->reduce($value[1]); + + return $value; + + case Type::T_FUNCTION_CALL: + list(, $name, $argValues) = $value; + + return $this->fncall($name, $argValues); + + default: + return $value; + } + } + + /** + * Function caller + * + * @param string $name + * @param array $argValues + * + * @return array|null + */ + private function fncall($name, $argValues) + { + // SCSS @function + if ($this->callScssFunction($name, $argValues, $returnValue)) { + return $returnValue; + } + + // native PHP functions + if ($this->callNativeFunction($name, $argValues, $returnValue)) { + return $returnValue; + } + + // for CSS functions, simply flatten the arguments into a list + $listArgs = []; + + foreach ((array) $argValues as $arg) { + if (empty($arg[0])) { + $listArgs[] = $this->reduce($arg[1]); + } + } + + return [Type::T_FUNCTION, $name, [Type::T_LIST, ',', $listArgs]]; + } + + /** + * Normalize name + * + * @param string $name + * + * @return string + */ + protected function normalizeName($name) + { + return str_replace('-', '_', $name); + } + + /** + * Normalize value + * + * @param array $value + * + * @return array + */ + public function normalizeValue($value) + { + $value = $this->coerceForExpression($this->reduce($value)); + list($type) = $value; + + switch ($type) { + case Type::T_LIST: + $value = $this->extractInterpolation($value); + + if ($value[0] !== Type::T_LIST) { + return [Type::T_KEYWORD, $this->compileValue($value)]; + } + + foreach ($value[2] as $key => $item) { + $value[2][$key] = $this->normalizeValue($item); + } + + return $value; + + case Type::T_STRING: + return [$type, '"', [$this->compileStringContent($value)]]; + + case Type::T_NUMBER: + return $value->normalize(); + + case Type::T_INTERPOLATE: + return [Type::T_KEYWORD, $this->compileValue($value)]; + + default: + return $value; + } + } + + /** + * Add numbers + * + * @param array $left + * @param array $right + * + * @return \Leafo\ScssPhp\Node\Number + */ + protected function opAddNumberNumber($left, $right) + { + return new Node\Number($left[1] + $right[1], $left[2]); + } + + /** + * Multiply numbers + * + * @param array $left + * @param array $right + * + * @return \Leafo\ScssPhp\Node\Number + */ + protected function opMulNumberNumber($left, $right) + { + return new Node\Number($left[1] * $right[1], $left[2]); + } + + /** + * Subtract numbers + * + * @param array $left + * @param array $right + * + * @return \Leafo\ScssPhp\Node\Number + */ + protected function opSubNumberNumber($left, $right) + { + return new Node\Number($left[1] - $right[1], $left[2]); + } + + /** + * Divide numbers + * + * @param array $left + * @param array $right + * + * @return array|\Leafo\ScssPhp\Node\Number + */ + protected function opDivNumberNumber($left, $right) + { + if ($right[1] == 0) { + return [Type::T_STRING, '', [$left[1] . $left[2] . '/' . $right[1] . $right[2]]]; + } + + return new Node\Number($left[1] / $right[1], $left[2]); + } + + /** + * Mod numbers + * + * @param array $left + * @param array $right + * + * @return \Leafo\ScssPhp\Node\Number + */ + protected function opModNumberNumber($left, $right) + { + return new Node\Number($left[1] % $right[1], $left[2]); + } + + /** + * Add strings + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opAdd($left, $right) + { + if ($strLeft = $this->coerceString($left)) { + if ($right[0] === Type::T_STRING) { + $right[1] = ''; + } + + $strLeft[2][] = $right; + + return $strLeft; + } + + if ($strRight = $this->coerceString($right)) { + if ($left[0] === Type::T_STRING) { + $left[1] = ''; + } + + array_unshift($strRight[2], $left); + + return $strRight; + } + } + + /** + * Boolean and + * + * @param array $left + * @param array $right + * @param boolean $shouldEval + * + * @return array + */ + protected function opAnd($left, $right, $shouldEval) + { + if (! $shouldEval) { + return; + } + + if ($left !== static::$false and $left !== static::$null) { + return $this->reduce($right, true); + } + + return $left; + } + + /** + * Boolean or + * + * @param array $left + * @param array $right + * @param boolean $shouldEval + * + * @return array + */ + protected function opOr($left, $right, $shouldEval) + { + if (! $shouldEval) { + return; + } + + if ($left !== static::$false and $left !== static::$null) { + return $left; + } + + return $this->reduce($right, true); + } + + /** + * Compare colors + * + * @param string $op + * @param array $left + * @param array $right + * + * @return array + */ + protected function opColorColor($op, $left, $right) + { + $out = [Type::T_COLOR]; + + foreach ([1, 2, 3] as $i) { + $lval = isset($left[$i]) ? $left[$i] : 0; + $rval = isset($right[$i]) ? $right[$i] : 0; + + switch ($op) { + case '+': + $out[] = $lval + $rval; + break; + + case '-': + $out[] = $lval - $rval; + break; + + case '*': + $out[] = $lval * $rval; + break; + + case '%': + $out[] = $lval % $rval; + break; + + case '/': + if ($rval == 0) { + $this->throwError("color: Can't divide by zero"); + break 2; + } + + $out[] = (int) ($lval / $rval); + break; + + case '==': + return $this->opEq($left, $right); + + case '!=': + return $this->opNeq($left, $right); + + default: + $this->throwError("color: unknown op $op"); + break 2; + } + } + + if (isset($left[4])) { + $out[4] = $left[4]; + } elseif (isset($right[4])) { + $out[4] = $right[4]; + } + + return $this->fixColor($out); + } + + /** + * Compare color and number + * + * @param string $op + * @param array $left + * @param array $right + * + * @return array + */ + protected function opColorNumber($op, $left, $right) + { + $value = $right[1]; + + return $this->opColorColor( + $op, + $left, + [Type::T_COLOR, $value, $value, $value] + ); + } + + /** + * Compare number and color + * + * @param string $op + * @param array $left + * @param array $right + * + * @return array + */ + protected function opNumberColor($op, $left, $right) + { + $value = $left[1]; + + return $this->opColorColor( + $op, + [Type::T_COLOR, $value, $value, $value], + $right + ); + } + + /** + * Compare number1 == number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opEq($left, $right) + { + if (($lStr = $this->coerceString($left)) && ($rStr = $this->coerceString($right))) { + $lStr[1] = ''; + $rStr[1] = ''; + + $left = $this->compileValue($lStr); + $right = $this->compileValue($rStr); + } + + return $this->toBool($left === $right); + } + + /** + * Compare number1 != number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opNeq($left, $right) + { + if (($lStr = $this->coerceString($left)) && ($rStr = $this->coerceString($right))) { + $lStr[1] = ''; + $rStr[1] = ''; + + $left = $this->compileValue($lStr); + $right = $this->compileValue($rStr); + } + + return $this->toBool($left !== $right); + } + + /** + * Compare number1 >= number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opGteNumberNumber($left, $right) + { + return $this->toBool($left[1] >= $right[1]); + } + + /** + * Compare number1 > number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opGtNumberNumber($left, $right) + { + return $this->toBool($left[1] > $right[1]); + } + + /** + * Compare number1 <= number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opLteNumberNumber($left, $right) + { + return $this->toBool($left[1] <= $right[1]); + } + + /** + * Compare number1 < number2 + * + * @param array $left + * @param array $right + * + * @return array + */ + protected function opLtNumberNumber($left, $right) + { + return $this->toBool($left[1] < $right[1]); + } + + /** + * Three-way comparison, aka spaceship operator + * + * @param array $left + * @param array $right + * + * @return \Leafo\ScssPhp\Node\Number + */ + protected function opCmpNumberNumber($left, $right) + { + $n = $left[1] - $right[1]; + + return new Node\Number($n ? $n / abs($n) : 0, ''); + } + + /** + * Cast to boolean + * + * @api + * + * @param mixed $thing + * + * @return array + */ + public function toBool($thing) + { + return $thing ? static::$true : static::$false; + } + + /** + * Compiles a primitive value into a CSS property value. + * + * Values in scssphp are typed by being wrapped in arrays, their format is + * typically: + * + * array(type, contents [, additional_contents]*) + * + * The input is expected to be reduced. This function will not work on + * things like expressions and variables. + * + * @api + * + * @param array $value + * + * @return string + */ + public function compileValue($value) + { + $value = $this->reduce($value); + + list($type) = $value; + + switch ($type) { + case Type::T_KEYWORD: + return $value[1]; + + case Type::T_COLOR: + // [1] - red component (either number for a %) + // [2] - green component + // [3] - blue component + // [4] - optional alpha component + list(, $r, $g, $b) = $value; + + $r = round($r); + $g = round($g); + $b = round($b); + + if (count($value) === 5 && $value[4] !== 1) { // rgba + return 'rgba(' . $r . ', ' . $g . ', ' . $b . ', ' . $value[4] . ')'; + } + + $h = sprintf('#%02x%02x%02x', $r, $g, $b); + + // Converting hex color to short notation (e.g. #003399 to #039) + if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) { + $h = '#' . $h[1] . $h[3] . $h[5]; + } + + return $h; + + case Type::T_NUMBER: + return $value->output($this); + + case Type::T_STRING: + return $value[1] . $this->compileStringContent($value) . $value[1]; + + case Type::T_FUNCTION: + $args = ! empty($value[2]) ? $this->compileValue($value[2]) : ''; + + return "$value[1]($args)"; + + case Type::T_LIST: + $value = $this->extractInterpolation($value); + + if ($value[0] !== Type::T_LIST) { + return $this->compileValue($value); + } + + list(, $delim, $items) = $value; + + if ($delim !== ' ') { + $delim .= ' '; + } + + $filtered = []; + + foreach ($items as $item) { + if ($item[0] === Type::T_NULL) { + continue; + } + + $filtered[] = $this->compileValue($item); + } + + return implode("$delim", $filtered); + + case Type::T_MAP: + $keys = $value[1]; + $values = $value[2]; + $filtered = []; + + for ($i = 0, $s = count($keys); $i < $s; $i++) { + $filtered[$this->compileValue($keys[$i])] = $this->compileValue($values[$i]); + } + + array_walk($filtered, function (&$value, $key) { + $value = $key . ': ' . $value; + }); + + return '(' . implode(', ', $filtered) . ')'; + + case Type::T_INTERPOLATED: + // node created by extractInterpolation + list(, $interpolate, $left, $right) = $value; + list(,, $whiteLeft, $whiteRight) = $interpolate; + + $left = count($left[2]) > 0 ? + $this->compileValue($left) . $whiteLeft : ''; + + $right = count($right[2]) > 0 ? + $whiteRight . $this->compileValue($right) : ''; + + return $left . $this->compileValue($interpolate) . $right; + + case Type::T_INTERPOLATE: + // raw parse node + list(, $exp) = $value; + + // strip quotes if it's a string + $reduced = $this->reduce($exp); + + switch ($reduced[0]) { + case Type::T_LIST: + $reduced = $this->extractInterpolation($reduced); + + if ($reduced[0] !== Type::T_LIST) { + break; + } + + list(, $delim, $items) = $reduced; + + if ($delim !== ' ') { + $delim .= ' '; + } + + $filtered = []; + + foreach ($items as $item) { + if ($item[0] === Type::T_NULL) { + continue; + } + + $temp = $this->compileValue([Type::T_KEYWORD, $item]); + if ($temp[0] === Type::T_STRING) { + $filtered[] = $this->compileStringContent($temp); + } elseif ($temp[0] === Type::T_KEYWORD) { + $filtered[] = $temp[1]; + } else { + $filtered[] = $this->compileValue($temp); + } + } + + $reduced = [Type::T_KEYWORD, implode("$delim", $filtered)]; + break; + + case Type::T_STRING: + $reduced = [Type::T_KEYWORD, $this->compileStringContent($reduced)]; + break; + + case Type::T_NULL: + $reduced = [Type::T_KEYWORD, '']; + } + + return $this->compileValue($reduced); + + case Type::T_NULL: + return 'null'; + + default: + $this->throwError("unknown value type: $type"); + } + } + + /** + * Flatten list + * + * @param array $list + * + * @return string + */ + protected function flattenList($list) + { + return $this->compileValue($list); + } + + /** + * Compile string content + * + * @param array $string + * + * @return string + */ + protected function compileStringContent($string) + { + $parts = []; + + foreach ($string[2] as $part) { + if (is_array($part) || $part instanceof \ArrayAccess) { + $parts[] = $this->compileValue($part); + } else { + $parts[] = $part; + } + } + + return implode($parts); + } + + /** + * Extract interpolation; it doesn't need to be recursive, compileValue will handle that + * + * @param array $list + * + * @return array + */ + protected function extractInterpolation($list) + { + $items = $list[2]; + + foreach ($items as $i => $item) { + if ($item[0] === Type::T_INTERPOLATE) { + $before = [Type::T_LIST, $list[1], array_slice($items, 0, $i)]; + $after = [Type::T_LIST, $list[1], array_slice($items, $i + 1)]; + + return [Type::T_INTERPOLATED, $item, $before, $after]; + } + } + + return $list; + } + + /** + * Find the final set of selectors + * + * @param \Leafo\ScssPhp\Compiler\Environment $env + * + * @return array + */ + protected function multiplySelectors(Environment $env) + { + $envs = $this->compactEnv($env); + $selectors = []; + $parentSelectors = [[]]; + + while ($env = array_pop($envs)) { + if (empty($env->selectors)) { + continue; + } + + $selectors = []; + + foreach ($env->selectors as $selector) { + foreach ($parentSelectors as $parent) { + $selectors[] = $this->joinSelectors($parent, $selector); + } + } + + $parentSelectors = $selectors; + } + + return $selectors; + } + + /** + * Join selectors; looks for & to replace, or append parent before child + * + * @param array $parent + * @param array $child + * + * @return array + */ + protected function joinSelectors($parent, $child) + { + $setSelf = false; + $out = []; + + foreach ($child as $part) { + $newPart = []; + + foreach ($part as $p) { + if ($p === static::$selfSelector) { + $setSelf = true; + + foreach ($parent as $i => $parentPart) { + if ($i > 0) { + $out[] = $newPart; + $newPart = []; + } + + foreach ($parentPart as $pp) { + $newPart[] = $pp; + } + } + } else { + $newPart[] = $p; + } + } + + $out[] = $newPart; + } + + return $setSelf ? $out : array_merge($parent, $child); + } + + /** + * Multiply media + * + * @param \Leafo\ScssPhp\Compiler\Environment $env + * @param array $childQueries + * + * @return array + */ + protected function multiplyMedia(Environment $env = null, $childQueries = null) + { + if (! isset($env) || + ! empty($env->block->type) && $env->block->type !== Type::T_MEDIA + ) { + return $childQueries; + } + + // plain old block, skip + if (empty($env->block->type)) { + return $this->multiplyMedia($env->parent, $childQueries); + } + + $parentQueries = isset($env->block->queryList) + ? $env->block->queryList + : [[[Type::T_MEDIA_VALUE, $env->block->value]]]; + + if ($childQueries === null) { + $childQueries = $parentQueries; + } else { + $originalQueries = $childQueries; + $childQueries = []; + + foreach ($parentQueries as $parentQuery) { + foreach ($originalQueries as $childQuery) { + $childQueries []= array_merge($parentQuery, $childQuery); + } + } + } + + return $this->multiplyMedia($env->parent, $childQueries); + } + + /** + * Convert env linked list to stack + * + * @param \Leafo\ScssPhp\Compiler\Environment $env + * + * @return array + */ + private function compactEnv(Environment $env) + { + for ($envs = []; $env; $env = $env->parent) { + $envs[] = $env; + } + + return $envs; + } + + /** + * Convert env stack to singly linked list + * + * @param array $envs + * + * @return \Leafo\ScssPhp\Compiler\Environment + */ + private function extractEnv($envs) + { + for ($env = null; $e = array_pop($envs);) { + $e->parent = $env; + $env = $e; + } + + return $env; + } + + /** + * Push environment + * + * @param \Leafo\ScssPhp\Block $block + * + * @return \Leafo\ScssPhp\Compiler\Environment + */ + protected function pushEnv(Block $block = null) + { + $env = new Environment; + $env->parent = $this->env; + $env->store = []; + $env->block = $block; + $env->depth = isset($this->env->depth) ? $this->env->depth + 1 : 0; + + $this->env = $env; + + return $env; + } + + /** + * Pop environment + */ + protected function popEnv() + { + $this->env = $this->env->parent; + } + + /** + * Get store environment + * + * @return \Leafo\ScssPhp\Compiler\Environment + */ + protected function getStoreEnv() + { + return isset($this->storeEnv) ? $this->storeEnv : $this->env; + } + + /** + * Set variable + * + * @param string $name + * @param mixed $value + * @param boolean $shadow + * @param \Leafo\ScssPhp\Compiler\Environment $env + */ + protected function set($name, $value, $shadow = false, Environment $env = null) + { + $name = $this->normalizeName($name); + + if (! isset($env)) { + $env = $this->getStoreEnv(); + } + + if ($shadow) { + $this->setRaw($name, $value, $env); + } else { + $this->setExisting($name, $value, $env); + } + } + + /** + * Set existing variable + * + * @param string $name + * @param mixed $value + * @param \Leafo\ScssPhp\Compiler\Environment $env + */ + protected function setExisting($name, $value, Environment $env) + { + $storeEnv = $env; + + $hasNamespace = $name[0] === '^' || $name[0] === '@' || $name[0] === '%'; + + for (;;) { + if (array_key_exists($name, $env->store)) { + break; + } + + if (! $hasNamespace && isset($env->marker)) { + $env = $storeEnv; + break; + } + + if (! isset($env->parent)) { + $env = $storeEnv; + break; + } + + $env = $env->parent; + } + + $env->store[$name] = $value; + } + + /** + * Set raw variable + * + * @param string $name + * @param mixed $value + * @param \Leafo\ScssPhp\Compiler\Environment $env + */ + protected function setRaw($name, $value, Environment $env) + { + $env->store[$name] = $value; + } + + /** + * Get variable + * + * @api + * + * @param string $name + * @param boolean $shouldThrow + * @param \Leafo\ScssPhp\Compiler\Environment $env + * + * @return mixed + */ + public function get($name, $shouldThrow = true, Environment $env = null) + { + $normalizedName = $this->normalizeName($name); + $specialContentKey = static::$namespaces['special'] . 'content'; + + if (! isset($env)) { + $env = $this->getStoreEnv(); + } + + $nextIsRoot = false; + $hasNamespace = $normalizedName[0] === '^' || $normalizedName[0] === '@' || $normalizedName[0] === '%'; + + for (;;) { + if (array_key_exists($normalizedName, $env->store)) { + return $env->store[$normalizedName]; + } + + if (! $hasNamespace && isset($env->marker)) { + if (! $nextIsRoot && ! empty($env->store[$specialContentKey])) { + $env = $env->store[$specialContentKey]->scope; + $nextIsRoot = true; + continue; + } + + $env = $this->rootEnv; + continue; + } + + if (! isset($env->parent)) { + break; + } + + $env = $env->parent; + } + + if ($shouldThrow) { + $this->throwError("Undefined variable \$$name"); + } + + // found nothing + } + + /** + * Has variable? + * + * @param string $name + * @param \Leafo\ScssPhp\Compiler\Environment $env + * + * @return boolean + */ + protected function has($name, Environment $env = null) + { + return $this->get($name, false, $env) !== null; + } + + /** + * Inject variables + * + * @param array $args + */ + protected function injectVariables(array $args) + { + if (empty($args)) { + return; + } + + $parser = $this->parserFactory(__METHOD__); + + foreach ($args as $name => $strValue) { + if ($name[0] === '$') { + $name = substr($name, 1); + } + + if (! $parser->parseValue($strValue, $value)) { + $value = $this->coerceValue($strValue); + } + + $this->set($name, $value); + } + } + + /** + * Set variables + * + * @api + * + * @param array $variables + */ + public function setVariables(array $variables) + { + $this->registeredVars = array_merge($this->registeredVars, $variables); + } + + /** + * Unset variable + * + * @api + * + * @param string $name + */ + public function unsetVariable($name) + { + unset($this->registeredVars[$name]); + } + + /** + * Returns list of variables + * + * @api + * + * @return array + */ + public function getVariables() + { + return $this->registeredVars; + } + + /** + * Adds to list of parsed files + * + * @api + * + * @param string $path + */ + public function addParsedFile($path) + { + if (isset($path) && file_exists($path)) { + $this->parsedFiles[realpath($path)] = filemtime($path); + } + } + + /** + * Returns list of parsed files + * + * @api + * + * @return array + */ + public function getParsedFiles() + { + return $this->parsedFiles; + } + + /** + * Add import path + * + * @api + * + * @param string $path + */ + public function addImportPath($path) + { + if (! in_array($path, $this->importPaths)) { + $this->importPaths[] = $path; + } + } + + /** + * Set import paths + * + * @api + * + * @param string|array $path + */ + public function setImportPaths($path) + { + $this->importPaths = (array) $path; + } + + /** + * Set number precision + * + * @api + * + * @param integer $numberPrecision + */ + public function setNumberPrecision($numberPrecision) + { + Node\Number::$precision = $numberPrecision; + } + + /** + * Set formatter + * + * @api + * + * @param string $formatterName + */ + public function setFormatter($formatterName) + { + $this->formatter = $formatterName; + } + + /** + * Set line number style + * + * @api + * + * @param string $lineNumberStyle + */ + public function setLineNumberStyle($lineNumberStyle) + { + $this->lineNumberStyle = $lineNumberStyle; + } + + /** + * Enable/disable source maps + * + * @api + * + * @param integer $sourceMap + */ + public function setSourceMap($sourceMap) + { + $this->sourceMap = $sourceMap; + } + + /** + * Set source map options + * + * @api + * + * @param array $sourceMapOptions + */ + public function setSourceMapOptions($sourceMapOptions) + { + $this->sourceMapOptions = $sourceMapOptions; + } + + /** + * Register function + * + * @api + * + * @param string $name + * @param callable $func + * @param array $prototype + */ + public function registerFunction($name, $func, $prototype = null) + { + $this->userFunctions[$this->normalizeName($name)] = [$func, $prototype]; + } + + /** + * Unregister function + * + * @api + * + * @param string $name + */ + public function unregisterFunction($name) + { + unset($this->userFunctions[$this->normalizeName($name)]); + } + + /** + * Add feature + * + * @api + * + * @param string $name + */ + public function addFeature($name) + { + $this->registeredFeatures[$name] = true; + } + + /** + * Import file + * + * @param string $path + * @param array $out + */ + protected function importFile($path, $out) + { + // see if tree is cached + $realPath = realpath($path); + + if (isset($this->importCache[$realPath])) { + $this->handleImportLoop($realPath); + + $tree = $this->importCache[$realPath]; + } else { + $code = file_get_contents($path); + $parser = $this->parserFactory($path); + $tree = $parser->parse($code); + + $this->importCache[$realPath] = $tree; + } + + $pi = pathinfo($path); + array_unshift($this->importPaths, $pi['dirname']); + $this->compileChildrenNoReturn($tree->children, $out); + array_shift($this->importPaths); + } + + /** + * Return the file path for an import url if it exists + * + * @api + * + * @param string $url + * + * @return string|null + */ + public function findImport($url) + { + $urls = []; + + // for "normal" scss imports (ignore vanilla css and external requests) + if (! preg_match('/\.css$|^https?:\/\//', $url)) { + // try both normal and the _partial filename + $urls = [$url, preg_replace('/[^\/]+$/', '_\0', $url)]; + } + + $hasExtension = preg_match('/[.]s?css$/', $url); + + foreach ($this->importPaths as $dir) { + if (is_string($dir)) { + // check urls for normal import paths + foreach ($urls as $full) { + $full = $dir + . (! empty($dir) && substr($dir, -1) !== '/' ? '/' : '') + . $full; + + if ($this->fileExists($file = $full . '.scss') || + ($hasExtension && $this->fileExists($file = $full)) + ) { + return $file; + } + } + } elseif (is_callable($dir)) { + // check custom callback for import path + $file = call_user_func($dir, $url); + + if ($file !== null) { + return $file; + } + } + } + + return null; + } + + /** + * Set encoding + * + * @api + * + * @param string $encoding + */ + public function setEncoding($encoding) + { + $this->encoding = $encoding; + } + + /** + * Ignore errors? + * + * @api + * + * @param boolean $ignoreErrors + * + * @return \Leafo\ScssPhp\Compiler + */ + public function setIgnoreErrors($ignoreErrors) + { + $this->ignoreErrors = $ignoreErrors; + } + + /** + * Throw error (exception) + * + * @api + * + * @param string $msg Message with optional sprintf()-style vararg parameters + * + * @throws \Leafo\ScssPhp\Exception\CompilerException + */ + public function throwError($msg) + { + if ($this->ignoreErrors) { + return; + } + + if (func_num_args() > 1) { + $msg = call_user_func_array('sprintf', func_get_args()); + } + + $line = $this->sourceLine; + $msg = "$msg: line: $line"; + + throw new CompilerException($msg); + } + + /** + * Handle import loop + * + * @param string $name + * + * @throws \Exception + */ + protected function handleImportLoop($name) + { + for ($env = $this->env; $env; $env = $env->parent) { + $file = $this->sourceNames[$env->block->sourceIndex]; + + if (realpath($file) === $name) { + $this->throwError('An @import loop has been found: %s imports %s', $file, basename($file)); + break; + } + } + } + + /** + * Does file exist? + * + * @param string $name + * + * @return boolean + */ + protected function fileExists($name) + { + return file_exists($name) && is_file($name); + } + + /** + * Call SCSS @function + * + * @param string $name + * @param array $argValues + * @param array $returnValue + * + * @return boolean Returns true if returnValue is set; otherwise, false + */ + protected function callScssFunction($name, $argValues, &$returnValue) + { + $func = $this->get(static::$namespaces['function'] . $name, false); + + if (! $func) { + return false; + } + + $this->pushEnv(); + + $storeEnv = $this->storeEnv; + $this->storeEnv = $this->env; + + // set the args + if (isset($func->args)) { + $this->applyArguments($func->args, $argValues); + } + + // throw away lines and children + $tmp = new OutputBlock; + $tmp->lines = []; + $tmp->children = []; + + $this->env->marker = 'function'; + + $ret = $this->compileChildren($func->children, $tmp); + + $this->storeEnv = $storeEnv; + + $this->popEnv(); + + $returnValue = ! isset($ret) ? static::$defaultValue : $ret; + + return true; + } + + /** + * Call built-in and registered (PHP) functions + * + * @param string $name + * @param array $args + * @param array $returnValue + * + * @return boolean Returns true if returnValue is set; otherwise, false + */ + protected function callNativeFunction($name, $args, &$returnValue) + { + // try a lib function + $name = $this->normalizeName($name); + + if (isset($this->userFunctions[$name])) { + // see if we can find a user function + list($f, $prototype) = $this->userFunctions[$name]; + } elseif (($f = $this->getBuiltinFunction($name)) && is_callable($f)) { + $libName = $f[1]; + $prototype = isset(static::$$libName) ? static::$$libName : null; + } else { + return false; + } + + list($sorted, $kwargs) = $this->sortArgs($prototype, $args); + + if ($name !== 'if' && $name !== 'call') { + foreach ($sorted as &$val) { + $val = $this->reduce($val, true); + } + } + + $returnValue = call_user_func($f, $sorted, $kwargs); + + if (! isset($returnValue)) { + return false; + } + + $returnValue = $this->coerceValue($returnValue); + + return true; + } + + /** + * Get built-in function + * + * @param string $name Normalized name + * + * @return array + */ + protected function getBuiltinFunction($name) + { + $libName = 'lib' . preg_replace_callback( + '/_(.)/', + function ($m) { + return ucfirst($m[1]); + }, + ucfirst($name) + ); + + return [$this, $libName]; + } + + /** + * Sorts keyword arguments + * + * @param array $prototype + * @param array $args + * + * @return array + */ + protected function sortArgs($prototype, $args) + { + $keyArgs = []; + $posArgs = []; + + // separate positional and keyword arguments + foreach ($args as $arg) { + list($key, $value) = $arg; + + $key = $key[1]; + + if (empty($key)) { + $posArgs[] = $value; + } else { + $keyArgs[$key] = $value; + } + } + + if (! isset($prototype)) { + return [$posArgs, $keyArgs]; + } + + // copy positional args + $finalArgs = array_pad($posArgs, count($prototype), null); + + // overwrite positional args with keyword args + foreach ($prototype as $i => $names) { + foreach ((array) $names as $name) { + if (isset($keyArgs[$name])) { + $finalArgs[$i] = $keyArgs[$name]; + } + } + } + + return [$finalArgs, $keyArgs]; + } + + /** + * Apply argument values per definition + * + * @param array $argDef + * @param array $argValues + * + * @throws \Exception + */ + protected function applyArguments($argDef, $argValues) + { + $storeEnv = $this->getStoreEnv(); + + $env = new Environment; + $env->store = $storeEnv->store; + + $hasVariable = false; + $args = []; + + foreach ($argDef as $i => $arg) { + list($name, $default, $isVariable) = $argDef[$i]; + + $args[$name] = [$i, $name, $default, $isVariable]; + $hasVariable |= $isVariable; + } + + $keywordArgs = []; + $deferredKeywordArgs = []; + $remaining = []; + + // assign the keyword args + foreach ((array) $argValues as $arg) { + if (! empty($arg[0])) { + if (! isset($args[$arg[0][1]])) { + if ($hasVariable) { + $deferredKeywordArgs[$arg[0][1]] = $arg[1]; + } else { + $this->throwError("Mixin or function doesn't have an argument named $%s.", $arg[0][1]); + break; + } + } elseif ($args[$arg[0][1]][0] < count($remaining)) { + $this->throwError("The argument $%s was passed both by position and by name.", $arg[0][1]); + break; + } else { + $keywordArgs[$arg[0][1]] = $arg[1]; + } + } elseif (count($keywordArgs)) { + $this->throwError('Positional arguments must come before keyword arguments.'); + break; + } elseif ($arg[2] === true) { + $val = $this->reduce($arg[1], true); + + if ($val[0] === Type::T_LIST) { + foreach ($val[2] as $name => $item) { + if (! is_numeric($name)) { + $keywordArgs[$name] = $item; + } else { + $remaining[] = $item; + } + } + } elseif ($val[0] === Type::T_MAP) { + foreach ($val[1] as $i => $name) { + $name = $this->compileStringContent($this->coerceString($name)); + $item = $val[2][$i]; + + if (! is_numeric($name)) { + $keywordArgs[$name] = $item; + } else { + $remaining[] = $item; + } + } + } else { + $remaining[] = $val; + } + } else { + $remaining[] = $arg[1]; + } + } + + foreach ($args as $arg) { + list($i, $name, $default, $isVariable) = $arg; + + if ($isVariable) { + $val = [Type::T_LIST, ',', [], $isVariable]; + + for ($count = count($remaining); $i < $count; $i++) { + $val[2][] = $remaining[$i]; + } + + foreach ($deferredKeywordArgs as $itemName => $item) { + $val[2][$itemName] = $item; + } + } elseif (isset($remaining[$i])) { + $val = $remaining[$i]; + } elseif (isset($keywordArgs[$name])) { + $val = $keywordArgs[$name]; + } elseif (! empty($default)) { + continue; + } else { + $this->throwError("Missing argument $name"); + break; + } + + $this->set($name, $this->reduce($val, true), true, $env); + } + + $storeEnv->store = $env->store; + + foreach ($args as $arg) { + list($i, $name, $default, $isVariable) = $arg; + + if ($isVariable || isset($remaining[$i]) || isset($keywordArgs[$name]) || empty($default)) { + continue; + } + + $this->set($name, $this->reduce($default, true), true); + } + } + + /** + * Coerce a php value into a scss one + * + * @param mixed $value + * + * @return array|\Leafo\ScssPhp\Node\Number + */ + private function coerceValue($value) + { + if (is_array($value) || $value instanceof \ArrayAccess) { + return $value; + } + + if (is_bool($value)) { + return $this->toBool($value); + } + + if ($value === null) { + return static::$null; + } + + if (is_numeric($value)) { + return new Node\Number($value, ''); + } + + if ($value === '') { + return static::$emptyString; + } + + if (preg_match('/^(#([0-9a-f]{6})|#([0-9a-f]{3}))$/i', $value, $m)) { + $color = [Type::T_COLOR]; + + if (isset($m[3])) { + $num = hexdec($m[3]); + + foreach ([3, 2, 1] as $i) { + $t = $num & 0xf; + $color[$i] = $t << 4 | $t; + $num >>= 4; + } + } else { + $num = hexdec($m[2]); + + foreach ([3, 2, 1] as $i) { + $color[$i] = $num & 0xff; + $num >>= 8; + } + } + + return $color; + } + + return [Type::T_KEYWORD, $value]; + } + + /** + * Coerce something to map + * + * @param array $item + * + * @return array + */ + protected function coerceMap($item) + { + if ($item[0] === Type::T_MAP) { + return $item; + } + + if ($item === static::$emptyList) { + return static::$emptyMap; + } + + return [Type::T_MAP, [$item], [static::$null]]; + } + + /** + * Coerce something to list + * + * @param array $item + * @param string $delim + * + * @return array + */ + protected function coerceList($item, $delim = ',') + { + if (isset($item) && $item[0] === Type::T_LIST) { + return $item; + } + + if (isset($item) && $item[0] === Type::T_MAP) { + $keys = $item[1]; + $values = $item[2]; + $list = []; + + for ($i = 0, $s = count($keys); $i < $s; $i++) { + $key = $keys[$i]; + $value = $values[$i]; + + $list[] = [ + Type::T_LIST, + '', + [[Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))], $value] + ]; + } + + return [Type::T_LIST, ',', $list]; + } + + return [Type::T_LIST, $delim, ! isset($item) ? []: [$item]]; + } + + /** + * Coerce color for expression + * + * @param array $value + * + * @return array|null + */ + protected function coerceForExpression($value) + { + if ($color = $this->coerceColor($value)) { + return $color; + } + + return $value; + } + + /** + * Coerce value to color + * + * @param array $value + * + * @return array|null + */ + protected function coerceColor($value) + { + switch ($value[0]) { + case Type::T_COLOR: + return $value; + + case Type::T_KEYWORD: + $name = strtolower($value[1]); + + if (isset(Colors::$cssColors[$name])) { + $rgba = explode(',', Colors::$cssColors[$name]); + + return isset($rgba[3]) + ? [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]] + : [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]]; + } + + return null; + } + + return null; + } + + /** + * Coerce value to string + * + * @param array $value + * + * @return array|null + */ + protected function coerceString($value) + { + if ($value[0] === Type::T_STRING) { + return $value; + } + + return [Type::T_STRING, '', [$this->compileValue($value)]]; + } + + /** + * Coerce value to a percentage + * + * @param array $value + * + * @return integer|float + */ + protected function coercePercent($value) + { + if ($value[0] === Type::T_NUMBER) { + if (! empty($value[2]['%'])) { + return $value[1] / 100; + } + + return $value[1]; + } + + return 0; + } + + /** + * Assert value is a map + * + * @api + * + * @param array $value + * + * @return array + * + * @throws \Exception + */ + public function assertMap($value) + { + $value = $this->coerceMap($value); + + if ($value[0] !== Type::T_MAP) { + $this->throwError('expecting map'); + } + + return $value; + } + + /** + * Assert value is a list + * + * @api + * + * @param array $value + * + * @return array + * + * @throws \Exception + */ + public function assertList($value) + { + if ($value[0] !== Type::T_LIST) { + $this->throwError('expecting list'); + } + + return $value; + } + + /** + * Assert value is a color + * + * @api + * + * @param array $value + * + * @return array + * + * @throws \Exception + */ + public function assertColor($value) + { + if ($color = $this->coerceColor($value)) { + return $color; + } + + $this->throwError('expecting color'); + } + + /** + * Assert value is a number + * + * @api + * + * @param array $value + * + * @return integer|float + * + * @throws \Exception + */ + public function assertNumber($value) + { + if ($value[0] !== Type::T_NUMBER) { + $this->throwError('expecting number'); + } + + return $value[1]; + } + + /** + * Make sure a color's components don't go out of bounds + * + * @param array $c + * + * @return array + */ + protected function fixColor($c) + { + foreach ([1, 2, 3] as $i) { + if ($c[$i] < 0) { + $c[$i] = 0; + } + + if ($c[$i] > 255) { + $c[$i] = 255; + } + } + + return $c; + } + + /** + * Convert RGB to HSL + * + * @api + * + * @param integer $red + * @param integer $green + * @param integer $blue + * + * @return array + */ + public function toHSL($red, $green, $blue) + { + $min = min($red, $green, $blue); + $max = max($red, $green, $blue); + + $l = $min + $max; + $d = $max - $min; + + if ((int) $d === 0) { + $h = $s = 0; + } else { + if ($l < 255) { + $s = $d / $l; + } else { + $s = $d / (510 - $l); + } + + if ($red == $max) { + $h = 60 * ($green - $blue) / $d; + } elseif ($green == $max) { + $h = 60 * ($blue - $red) / $d + 120; + } elseif ($blue == $max) { + $h = 60 * ($red - $green) / $d + 240; + } + } + + return [Type::T_HSL, fmod($h, 360), $s * 100, $l / 5.1]; + } + + /** + * Hue to RGB helper + * + * @param float $m1 + * @param float $m2 + * @param float $h + * + * @return float + */ + private function hueToRGB($m1, $m2, $h) + { + if ($h < 0) { + $h += 1; + } elseif ($h > 1) { + $h -= 1; + } + + if ($h * 6 < 1) { + return $m1 + ($m2 - $m1) * $h * 6; + } + + if ($h * 2 < 1) { + return $m2; + } + + if ($h * 3 < 2) { + return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; + } + + return $m1; + } + + /** + * Convert HSL to RGB + * + * @api + * + * @param integer $hue H from 0 to 360 + * @param integer $saturation S from 0 to 100 + * @param integer $lightness L from 0 to 100 + * + * @return array + */ + public function toRGB($hue, $saturation, $lightness) + { + if ($hue < 0) { + $hue += 360; + } + + $h = $hue / 360; + $s = min(100, max(0, $saturation)) / 100; + $l = min(100, max(0, $lightness)) / 100; + + $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s; + $m1 = $l * 2 - $m2; + + $r = $this->hueToRGB($m1, $m2, $h + 1/3) * 255; + $g = $this->hueToRGB($m1, $m2, $h) * 255; + $b = $this->hueToRGB($m1, $m2, $h - 1/3) * 255; + + $out = [Type::T_COLOR, $r, $g, $b]; + + return $out; + } + + // Built in functions + + //protected static $libCall = ['name', 'args...']; + protected function libCall($args, $kwargs) + { + $name = $this->compileStringContent($this->coerceString($this->reduce(array_shift($args), true))); + + $args = array_map( + function ($a) { + return [null, $a, false]; + }, + $args + ); + + if (count($kwargs)) { + foreach ($kwargs as $key => $value) { + $args[] = [[Type::T_VARIABLE, $key], $value, false]; + } + } + + return $this->reduce([Type::T_FUNCTION_CALL, $name, $args]); + } + + protected static $libIf = ['condition', 'if-true', 'if-false']; + protected function libIf($args) + { + list($cond, $t, $f) = $args; + + if (! $this->isTruthy($this->reduce($cond, true))) { + return $this->reduce($f, true); + } + + return $this->reduce($t, true); + } + + protected static $libIndex = ['list', 'value']; + protected function libIndex($args) + { + list($list, $value) = $args; + + if ($value[0] === Type::T_MAP) { + return static::$null; + } + + if ($list[0] === Type::T_MAP || + $list[0] === Type::T_STRING || + $list[0] === Type::T_KEYWORD || + $list[0] === Type::T_INTERPOLATE + ) { + $list = $this->coerceList($list, ' '); + } + + if ($list[0] !== Type::T_LIST) { + return static::$null; + } + + $values = []; + + foreach ($list[2] as $item) { + $values[] = $this->normalizeValue($item); + } + + $key = array_search($this->normalizeValue($value), $values); + + return false === $key ? static::$null : $key + 1; + } + + protected static $libRgb = ['red', 'green', 'blue']; + protected function libRgb($args) + { + list($r, $g, $b) = $args; + + return [Type::T_COLOR, $r[1], $g[1], $b[1]]; + } + + protected static $libRgba = [ + ['red', 'color'], + 'green', 'blue', 'alpha']; + protected function libRgba($args) + { + if ($color = $this->coerceColor($args[0])) { + $num = ! isset($args[1]) ? $args[3] : $args[1]; + $alpha = $this->assertNumber($num); + $color[4] = $alpha; + + return $color; + } + + list($r, $g, $b, $a) = $args; + + return [Type::T_COLOR, $r[1], $g[1], $b[1], $a[1]]; + } + + // helper function for adjust_color, change_color, and scale_color + protected function alterColor($args, $fn) + { + $color = $this->assertColor($args[0]); + + foreach ([1, 2, 3, 7] as $i) { + if (isset($args[$i])) { + $val = $this->assertNumber($args[$i]); + $ii = $i === 7 ? 4 : $i; // alpha + $color[$ii] = call_user_func($fn, isset($color[$ii]) ? $color[$ii] : 0, $val, $i); + } + } + + if (isset($args[4]) || isset($args[5]) || isset($args[6])) { + $hsl = $this->toHSL($color[1], $color[2], $color[3]); + + foreach ([4, 5, 6] as $i) { + if (isset($args[$i])) { + $val = $this->assertNumber($args[$i]); + $hsl[$i - 3] = call_user_func($fn, $hsl[$i - 3], $val, $i); + } + } + + $rgb = $this->toRGB($hsl[1], $hsl[2], $hsl[3]); + + if (isset($color[4])) { + $rgb[4] = $color[4]; + } + + $color = $rgb; + } + + return $color; + } + + protected static $libAdjustColor = [ + 'color', 'red', 'green', 'blue', + 'hue', 'saturation', 'lightness', 'alpha' + ]; + protected function libAdjustColor($args) + { + return $this->alterColor($args, function ($base, $alter, $i) { + return $base + $alter; + }); + } + + protected static $libChangeColor = [ + 'color', 'red', 'green', 'blue', + 'hue', 'saturation', 'lightness', 'alpha' + ]; + protected function libChangeColor($args) + { + return $this->alterColor($args, function ($base, $alter, $i) { + return $alter; + }); + } + + protected static $libScaleColor = [ + 'color', 'red', 'green', 'blue', + 'hue', 'saturation', 'lightness', 'alpha' + ]; + protected function libScaleColor($args) + { + return $this->alterColor($args, function ($base, $scale, $i) { + // 1, 2, 3 - rgb + // 4, 5, 6 - hsl + // 7 - a + switch ($i) { + case 1: + case 2: + case 3: + $max = 255; + break; + + case 4: + $max = 360; + break; + + case 7: + $max = 1; + break; + + default: + $max = 100; + } + + $scale = $scale / 100; + + if ($scale < 0) { + return $base * $scale + $base; + } + + return ($max - $base) * $scale + $base; + }); + } + + protected static $libIeHexStr = ['color']; + protected function libIeHexStr($args) + { + $color = $this->coerceColor($args[0]); + $color[4] = isset($color[4]) ? round(255 * $color[4]) : 255; + + return sprintf('#%02X%02X%02X%02X', $color[4], $color[1], $color[2], $color[3]); + } + + protected static $libRed = ['color']; + protected function libRed($args) + { + $color = $this->coerceColor($args[0]); + + return $color[1]; + } + + protected static $libGreen = ['color']; + protected function libGreen($args) + { + $color = $this->coerceColor($args[0]); + + return $color[2]; + } + + protected static $libBlue = ['color']; + protected function libBlue($args) + { + $color = $this->coerceColor($args[0]); + + return $color[3]; + } + + protected static $libAlpha = ['color']; + protected function libAlpha($args) + { + if ($color = $this->coerceColor($args[0])) { + return isset($color[4]) ? $color[4] : 1; + } + + // this might be the IE function, so return value unchanged + return null; + } + + protected static $libOpacity = ['color']; + protected function libOpacity($args) + { + $value = $args[0]; + + if ($value[0] === Type::T_NUMBER) { + return null; + } + + return $this->libAlpha($args); + } + + // mix two colors + protected static $libMix = ['color-1', 'color-2', 'weight']; + protected function libMix($args) + { + list($first, $second, $weight) = $args; + + $first = $this->assertColor($first); + $second = $this->assertColor($second); + + if (! isset($weight)) { + $weight = 0.5; + } else { + $weight = $this->coercePercent($weight); + } + + $firstAlpha = isset($first[4]) ? $first[4] : 1; + $secondAlpha = isset($second[4]) ? $second[4] : 1; + + $w = $weight * 2 - 1; + $a = $firstAlpha - $secondAlpha; + + $w1 = (($w * $a === -1 ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2.0; + $w2 = 1.0 - $w1; + + $new = [Type::T_COLOR, + $w1 * $first[1] + $w2 * $second[1], + $w1 * $first[2] + $w2 * $second[2], + $w1 * $first[3] + $w2 * $second[3], + ]; + + if ($firstAlpha != 1.0 || $secondAlpha != 1.0) { + $new[] = $firstAlpha * $weight + $secondAlpha * ($weight - 1); + } + + return $this->fixColor($new); + } + + protected static $libHsl = ['hue', 'saturation', 'lightness']; + protected function libHsl($args) + { + list($h, $s, $l) = $args; + + return $this->toRGB($h[1], $s[1], $l[1]); + } + + protected static $libHsla = ['hue', 'saturation', 'lightness', 'alpha']; + protected function libHsla($args) + { + list($h, $s, $l, $a) = $args; + + $color = $this->toRGB($h[1], $s[1], $l[1]); + $color[4] = $a[1]; + + return $color; + } + + protected static $libHue = ['color']; + protected function libHue($args) + { + $color = $this->assertColor($args[0]); + $hsl = $this->toHSL($color[1], $color[2], $color[3]); + + return new Node\Number($hsl[1], 'deg'); + } + + protected static $libSaturation = ['color']; + protected function libSaturation($args) + { + $color = $this->assertColor($args[0]); + $hsl = $this->toHSL($color[1], $color[2], $color[3]); + + return new Node\Number($hsl[2], '%'); + } + + protected static $libLightness = ['color']; + protected function libLightness($args) + { + $color = $this->assertColor($args[0]); + $hsl = $this->toHSL($color[1], $color[2], $color[3]); + + return new Node\Number($hsl[3], '%'); + } + + protected function adjustHsl($color, $idx, $amount) + { + $hsl = $this->toHSL($color[1], $color[2], $color[3]); + $hsl[$idx] += $amount; + $out = $this->toRGB($hsl[1], $hsl[2], $hsl[3]); + + if (isset($color[4])) { + $out[4] = $color[4]; + } + + return $out; + } + + protected static $libAdjustHue = ['color', 'degrees']; + protected function libAdjustHue($args) + { + $color = $this->assertColor($args[0]); + $degrees = $this->assertNumber($args[1]); + + return $this->adjustHsl($color, 1, $degrees); + } + + protected static $libLighten = ['color', 'amount']; + protected function libLighten($args) + { + $color = $this->assertColor($args[0]); + $amount = Util::checkRange('amount', new Range(0, 100), $args[1], '%'); + + return $this->adjustHsl($color, 3, $amount); + } + + protected static $libDarken = ['color', 'amount']; + protected function libDarken($args) + { + $color = $this->assertColor($args[0]); + $amount = Util::checkRange('amount', new Range(0, 100), $args[1], '%'); + + return $this->adjustHsl($color, 3, -$amount); + } + + protected static $libSaturate = ['color', 'amount']; + protected function libSaturate($args) + { + $value = $args[0]; + + if ($value[0] === Type::T_NUMBER) { + return null; + } + + $color = $this->assertColor($value); + $amount = 100 * $this->coercePercent($args[1]); + + return $this->adjustHsl($color, 2, $amount); + } + + protected static $libDesaturate = ['color', 'amount']; + protected function libDesaturate($args) + { + $color = $this->assertColor($args[0]); + $amount = 100 * $this->coercePercent($args[1]); + + return $this->adjustHsl($color, 2, -$amount); + } + + protected static $libGrayscale = ['color']; + protected function libGrayscale($args) + { + $value = $args[0]; + + if ($value[0] === Type::T_NUMBER) { + return null; + } + + return $this->adjustHsl($this->assertColor($value), 2, -100); + } + + protected static $libComplement = ['color']; + protected function libComplement($args) + { + return $this->adjustHsl($this->assertColor($args[0]), 1, 180); + } + + protected static $libInvert = ['color']; + protected function libInvert($args) + { + $value = $args[0]; + + if ($value[0] === Type::T_NUMBER) { + return null; + } + + $color = $this->assertColor($value); + $color[1] = 255 - $color[1]; + $color[2] = 255 - $color[2]; + $color[3] = 255 - $color[3]; + + return $color; + } + + // increases opacity by amount + protected static $libOpacify = ['color', 'amount']; + protected function libOpacify($args) + { + $color = $this->assertColor($args[0]); + $amount = $this->coercePercent($args[1]); + + $color[4] = (isset($color[4]) ? $color[4] : 1) + $amount; + $color[4] = min(1, max(0, $color[4])); + + return $color; + } + + protected static $libFadeIn = ['color', 'amount']; + protected function libFadeIn($args) + { + return $this->libOpacify($args); + } + + // decreases opacity by amount + protected static $libTransparentize = ['color', 'amount']; + protected function libTransparentize($args) + { + $color = $this->assertColor($args[0]); + $amount = $this->coercePercent($args[1]); + + $color[4] = (isset($color[4]) ? $color[4] : 1) - $amount; + $color[4] = min(1, max(0, $color[4])); + + return $color; + } + + protected static $libFadeOut = ['color', 'amount']; + protected function libFadeOut($args) + { + return $this->libTransparentize($args); + } + + protected static $libUnquote = ['string']; + protected function libUnquote($args) + { + $str = $args[0]; + + if ($str[0] === Type::T_STRING) { + $str[1] = ''; + } + + return $str; + } + + protected static $libQuote = ['string']; + protected function libQuote($args) + { + $value = $args[0]; + + if ($value[0] === Type::T_STRING && ! empty($value[1])) { + return $value; + } + + return [Type::T_STRING, '"', [$value]]; + } + + protected static $libPercentage = ['value']; + protected function libPercentage($args) + { + return new Node\Number($this->coercePercent($args[0]) * 100, '%'); + } + + protected static $libRound = ['value']; + protected function libRound($args) + { + $num = $args[0]; + + return new Node\Number(round($num[1]), $num[2]); + } + + protected static $libFloor = ['value']; + protected function libFloor($args) + { + $num = $args[0]; + + return new Node\Number(floor($num[1]), $num[2]); + } + + protected static $libCeil = ['value']; + protected function libCeil($args) + { + $num = $args[0]; + + return new Node\Number(ceil($num[1]), $num[2]); + } + + protected static $libAbs = ['value']; + protected function libAbs($args) + { + $num = $args[0]; + + return new Node\Number(abs($num[1]), $num[2]); + } + + protected function libMin($args) + { + $numbers = $this->getNormalizedNumbers($args); + $min = null; + + foreach ($numbers as $key => $number) { + if (null === $min || $number[1] <= $min[1]) { + $min = [$key, $number[1]]; + } + } + + return $args[$min[0]]; + } + + protected function libMax($args) + { + $numbers = $this->getNormalizedNumbers($args); + $max = null; + + foreach ($numbers as $key => $number) { + if (null === $max || $number[1] >= $max[1]) { + $max = [$key, $number[1]]; + } + } + + return $args[$max[0]]; + } + + /** + * Helper to normalize args containing numbers + * + * @param array $args + * + * @return array + */ + protected function getNormalizedNumbers($args) + { + $unit = null; + $originalUnit = null; + $numbers = []; + + foreach ($args as $key => $item) { + if ($item[0] !== Type::T_NUMBER) { + $this->throwError('%s is not a number', $item[0]); + break; + } + + $number = $item->normalize(); + + if (null === $unit) { + $unit = $number[2]; + $originalUnit = $item->unitStr(); + } elseif ($unit !== $number[2]) { + $this->throwError('Incompatible units: "%s" and "%s".', $originalUnit, $item->unitStr()); + break; + } + + $numbers[$key] = $number; + } + + return $numbers; + } + + protected static $libLength = ['list']; + protected function libLength($args) + { + $list = $this->coerceList($args[0]); + + return count($list[2]); + } + + //protected static $libListSeparator = ['list...']; + protected function libListSeparator($args) + { + if (count($args) > 1) { + return 'comma'; + } + + $list = $this->coerceList($args[0]); + + if (count($list[2]) <= 1) { + return 'space'; + } + + if ($list[1] === ',') { + return 'comma'; + } + + return 'space'; + } + + protected static $libNth = ['list', 'n']; + protected function libNth($args) + { + $list = $this->coerceList($args[0]); + $n = $this->assertNumber($args[1]); + + if ($n > 0) { + $n--; + } elseif ($n < 0) { + $n += count($list[2]); + } + + return isset($list[2][$n]) ? $list[2][$n] : static::$defaultValue; + } + + protected static $libSetNth = ['list', 'n', 'value']; + protected function libSetNth($args) + { + $list = $this->coerceList($args[0]); + $n = $this->assertNumber($args[1]); + + if ($n > 0) { + $n--; + } elseif ($n < 0) { + $n += count($list[2]); + } + + if (! isset($list[2][$n])) { + $this->throwError('Invalid argument for "n"'); + + return; + } + + $list[2][$n] = $args[2]; + + return $list; + } + + protected static $libMapGet = ['map', 'key']; + protected function libMapGet($args) + { + $map = $this->assertMap($args[0]); + $key = $this->compileStringContent($this->coerceString($args[1])); + + for ($i = count($map[1]) - 1; $i >= 0; $i--) { + if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { + return $map[2][$i]; + } + } + + return static::$null; + } + + protected static $libMapKeys = ['map']; + protected function libMapKeys($args) + { + $map = $this->assertMap($args[0]); + $keys = $map[1]; + + return [Type::T_LIST, ',', $keys]; + } + + protected static $libMapValues = ['map']; + protected function libMapValues($args) + { + $map = $this->assertMap($args[0]); + $values = $map[2]; + + return [Type::T_LIST, ',', $values]; + } + + protected static $libMapRemove = ['map', 'key']; + protected function libMapRemove($args) + { + $map = $this->assertMap($args[0]); + $key = $this->compileStringContent($this->coerceString($args[1])); + + for ($i = count($map[1]) - 1; $i >= 0; $i--) { + if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { + array_splice($map[1], $i, 1); + array_splice($map[2], $i, 1); + } + } + + return $map; + } + + protected static $libMapHasKey = ['map', 'key']; + protected function libMapHasKey($args) + { + $map = $this->assertMap($args[0]); + $key = $this->compileStringContent($this->coerceString($args[1])); + + for ($i = count($map[1]) - 1; $i >= 0; $i--) { + if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { + return true; + } + } + + return false; + } + + protected static $libMapMerge = ['map-1', 'map-2']; + protected function libMapMerge($args) + { + $map1 = $this->assertMap($args[0]); + $map2 = $this->assertMap($args[1]); + + return [Type::T_MAP, array_merge($map1[1], $map2[1]), array_merge($map1[2], $map2[2])]; + } + + protected static $libKeywords = ['args']; + protected function libKeywords($args) + { + $this->assertList($args[0]); + + $keys = []; + $values = []; + + foreach ($args[0][2] as $name => $arg) { + $keys[] = [Type::T_KEYWORD, $name]; + $values[] = $arg; + } + + return [Type::T_MAP, $keys, $values]; + } + + protected function listSeparatorForJoin($list1, $sep) + { + if (! isset($sep)) { + return $list1[1]; + } + + switch ($this->compileValue($sep)) { + case 'comma': + return ','; + + case 'space': + return ''; + + default: + return $list1[1]; + } + } + + protected static $libJoin = ['list1', 'list2', 'separator']; + protected function libJoin($args) + { + list($list1, $list2, $sep) = $args; + + $list1 = $this->coerceList($list1, ' '); + $list2 = $this->coerceList($list2, ' '); + $sep = $this->listSeparatorForJoin($list1, $sep); + + return [Type::T_LIST, $sep, array_merge($list1[2], $list2[2])]; + } + + protected static $libAppend = ['list', 'val', 'separator']; + protected function libAppend($args) + { + list($list1, $value, $sep) = $args; + + $list1 = $this->coerceList($list1, ' '); + $sep = $this->listSeparatorForJoin($list1, $sep); + + return [Type::T_LIST, $sep, array_merge($list1[2], [$value])]; + } + + protected function libZip($args) + { + foreach ($args as $arg) { + $this->assertList($arg); + } + + $lists = []; + $firstList = array_shift($args); + + foreach ($firstList[2] as $key => $item) { + $list = [Type::T_LIST, '', [$item]]; + + foreach ($args as $arg) { + if (isset($arg[2][$key])) { + $list[2][] = $arg[2][$key]; + } else { + break 2; + } + } + + $lists[] = $list; + } + + return [Type::T_LIST, ',', $lists]; + } + + protected static $libTypeOf = ['value']; + protected function libTypeOf($args) + { + $value = $args[0]; + + switch ($value[0]) { + case Type::T_KEYWORD: + if ($value === static::$true || $value === static::$false) { + return 'bool'; + } + + if ($this->coerceColor($value)) { + return 'color'; + } + + // fall-thru + case Type::T_FUNCTION: + return 'string'; + + case Type::T_LIST: + if (isset($value[3]) && $value[3]) { + return 'arglist'; + } + + // fall-thru + default: + return $value[0]; + } + } + + protected static $libUnit = ['number']; + protected function libUnit($args) + { + $num = $args[0]; + + if ($num[0] === Type::T_NUMBER) { + return [Type::T_STRING, '"', [$num->unitStr()]]; + } + + return ''; + } + + protected static $libUnitless = ['number']; + protected function libUnitless($args) + { + $value = $args[0]; + + return $value[0] === Type::T_NUMBER && $value->unitless(); + } + + protected static $libComparable = ['number-1', 'number-2']; + protected function libComparable($args) + { + list($number1, $number2) = $args; + + if (! isset($number1[0]) || $number1[0] !== Type::T_NUMBER || + ! isset($number2[0]) || $number2[0] !== Type::T_NUMBER + ) { + $this->throwError('Invalid argument(s) for "comparable"'); + + return; + } + + $number1 = $number1->normalize(); + $number2 = $number2->normalize(); + + return $number1[2] === $number2[2] || $number1->unitless() || $number2->unitless(); + } + + protected static $libStrIndex = ['string', 'substring']; + protected function libStrIndex($args) + { + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + $substring = $this->coerceString($args[1]); + $substringContent = $this->compileStringContent($substring); + + $result = strpos($stringContent, $substringContent); + + return $result === false ? static::$null : new Node\Number($result + 1, ''); + } + + protected static $libStrInsert = ['string', 'insert', 'index']; + protected function libStrInsert($args) + { + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + $insert = $this->coerceString($args[1]); + $insertContent = $this->compileStringContent($insert); + + list(, $index) = $args[2]; + + $string[2] = [substr_replace($stringContent, $insertContent, $index - 1, 0)]; + + return $string; + } + + protected static $libStrLength = ['string']; + protected function libStrLength($args) + { + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + return new Node\Number(strlen($stringContent), ''); + } + + protected static $libStrSlice = ['string', 'start-at', 'end-at']; + protected function libStrSlice($args) + { + if (isset($args[2]) && $args[2][1] == 0) { + return static::$nullString; + } + + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + $start = (int) $args[1][1]; + + if ($start > 0) { + $start--; + } + + $end = (int) $args[2][1]; + $length = $end < 0 ? $end + 1 : ($end > 0 ? $end - $start : $end); + + $string[2] = $length + ? [substr($stringContent, $start, $length)] + : [substr($stringContent, $start)]; + + return $string; + } + + protected static $libToLowerCase = ['string']; + protected function libToLowerCase($args) + { + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + $string[2] = [function_exists('mb_strtolower') ? mb_strtolower($stringContent) : strtolower($stringContent)]; + + return $string; + } + + protected static $libToUpperCase = ['string']; + protected function libToUpperCase($args) + { + $string = $this->coerceString($args[0]); + $stringContent = $this->compileStringContent($string); + + $string[2] = [function_exists('mb_strtoupper') ? mb_strtoupper($stringContent) : strtoupper($stringContent)]; + + return $string; + } + + protected static $libFeatureExists = ['feature']; + protected function libFeatureExists($args) + { + $string = $this->coerceString($args[0]); + $name = $this->compileStringContent($string); + + return $this->toBool( + array_key_exists($name, $this->registeredFeatures) ? $this->registeredFeatures[$name] : false + ); + } + + protected static $libFunctionExists = ['name']; + protected function libFunctionExists($args) + { + $string = $this->coerceString($args[0]); + $name = $this->compileStringContent($string); + + // user defined functions + if ($this->has(static::$namespaces['function'] . $name)) { + return true; + } + + $name = $this->normalizeName($name); + + if (isset($this->userFunctions[$name])) { + return true; + } + + // built-in functions + $f = $this->getBuiltinFunction($name); + + return $this->toBool(is_callable($f)); + } + + protected static $libGlobalVariableExists = ['name']; + protected function libGlobalVariableExists($args) + { + $string = $this->coerceString($args[0]); + $name = $this->compileStringContent($string); + + return $this->has($name, $this->rootEnv); + } + + protected static $libMixinExists = ['name']; + protected function libMixinExists($args) + { + $string = $this->coerceString($args[0]); + $name = $this->compileStringContent($string); + + return $this->has(static::$namespaces['mixin'] . $name); + } + + protected static $libVariableExists = ['name']; + protected function libVariableExists($args) + { + $string = $this->coerceString($args[0]); + $name = $this->compileStringContent($string); + + return $this->has($name); + } + + /** + * Workaround IE7's content counter bug. + * + * @param array $args + * + * @return array + */ + protected function libCounter($args) + { + $list = array_map([$this, 'compileValue'], $args); + + return [Type::T_STRING, '', ['counter(' . implode(',', $list) . ')']]; + } + + protected static $libRandom = ['limit']; + protected function libRandom($args) + { + if (isset($args[0])) { + $n = $this->assertNumber($args[0]); + + if ($n < 1) { + $this->throwError("limit must be greater than or equal to 1"); + + return; + } + + return new Node\Number(mt_rand(1, $n), ''); + } + + return new Node\Number(mt_rand(1, mt_getrandmax()), ''); + } + + protected function libUniqueId() + { + static $id; + + if (! isset($id)) { + $id = mt_rand(0, pow(36, 8)); + } + + $id += mt_rand(0, 10) + 1; + + return [Type::T_STRING, '', ['u' . str_pad(base_convert($id, 10, 36), 8, '0', STR_PAD_LEFT)]]; + } + + protected static $libInspect = ['value']; + protected function libInspect($args) + { + if ($args[0] === static::$null) { + return [Type::T_KEYWORD, 'null']; + } + + return $args[0]; + } +} diff --git a/inc/scssphp--old/src/Compiler/Environment.php b/inc/scssphp--old/src/Compiler/Environment.php new file mode 100644 index 0000000..fe309dd --- /dev/null +++ b/inc/scssphp--old/src/Compiler/Environment.php @@ -0,0 +1,40 @@ + + */ +class Environment +{ + /** + * @var \Leafo\ScssPhp\Block + */ + public $block; + + /** + * @var \Leafo\ScssPhp\Compiler\Environment + */ + public $parent; + + /** + * @var array + */ + public $store; + + /** + * @var integer + */ + public $depth; +} diff --git a/inc/scssphp--old/src/Exception/CompilerException.php b/inc/scssphp--old/src/Exception/CompilerException.php new file mode 100644 index 0000000..7ca2e2b --- /dev/null +++ b/inc/scssphp--old/src/Exception/CompilerException.php @@ -0,0 +1,21 @@ + + */ +class CompilerException extends \Exception +{ +} diff --git a/inc/scssphp--old/src/Exception/ParserException.php b/inc/scssphp--old/src/Exception/ParserException.php new file mode 100644 index 0000000..6d64335 --- /dev/null +++ b/inc/scssphp--old/src/Exception/ParserException.php @@ -0,0 +1,21 @@ + + */ +class ParserException extends \Exception +{ +} diff --git a/inc/scssphp--old/src/Exception/RangeException.php b/inc/scssphp--old/src/Exception/RangeException.php new file mode 100644 index 0000000..3ba6bf1 --- /dev/null +++ b/inc/scssphp--old/src/Exception/RangeException.php @@ -0,0 +1,21 @@ + + */ +class RangeException extends \Exception +{ +} diff --git a/inc/scssphp--old/src/Exception/ServerException.php b/inc/scssphp--old/src/Exception/ServerException.php new file mode 100644 index 0000000..d0ed084 --- /dev/null +++ b/inc/scssphp--old/src/Exception/ServerException.php @@ -0,0 +1,21 @@ + + */ +class ServerException extends \Exception +{ +} diff --git a/inc/scssphp--old/src/Formatter.php b/inc/scssphp--old/src/Formatter.php new file mode 100644 index 0000000..b4f90aa --- /dev/null +++ b/inc/scssphp--old/src/Formatter.php @@ -0,0 +1,274 @@ + + */ +abstract class Formatter +{ + /** + * @var integer + */ + public $indentLevel; + + /** + * @var string + */ + public $indentChar; + + /** + * @var string + */ + public $break; + + /** + * @var string + */ + public $open; + + /** + * @var string + */ + public $close; + + /** + * @var string + */ + public $tagSeparator; + + /** + * @var string + */ + public $assignSeparator; + + /** + * @var boolean + */ + public $keepSemicolons; + + /** + * @var \Leafo\ScssPhp\Formatter\OutputBlock + */ + protected $currentBlock; + + /** + * @var integer + */ + protected $currentLine; + + /** + * @var integer + */ + protected $currentColumn; + + /** + * @var \Leafo\ScssPhp\SourceMap\SourceMapGenerator + */ + protected $sourceMapGenerator; + + /** + * Initialize formatter + * + * @api + */ + abstract public function __construct(); + + /** + * Return indentation (whitespace) + * + * @return string + */ + protected function indentStr() + { + return ''; + } + + /** + * Return property assignment + * + * @api + * + * @param string $name + * @param mixed $value + * + * @return string + */ + public function property($name, $value) + { + return rtrim($name) . $this->assignSeparator . $value . ';'; + } + + /** + * Strip semi-colon appended by property(); it's a separator, not a terminator + * + * @api + * + * @param array $lines + */ + public function stripSemicolon(&$lines) + { + if ($this->keepSemicolons) { + return; + } + + if (($count = count($lines)) + && substr($lines[$count - 1], -1) === ';' + ) { + $lines[$count - 1] = substr($lines[$count - 1], 0, -1); + } + } + + /** + * Output lines inside a block + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + */ + protected function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + $this->write($inner . implode($glue, $block->lines)); + + if (! empty($block->children)) { + $this->write($this->break); + } + } + + /** + * Output block selectors + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + */ + protected function blockSelectors(OutputBlock $block) + { + $inner = $this->indentStr(); + + $this->write($inner + . implode($this->tagSeparator, $block->selectors) + . $this->open . $this->break); + } + + /** + * Output block children + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + */ + protected function blockChildren(OutputBlock $block) + { + foreach ($block->children as $child) { + $this->block($child); + } + } + + /** + * Output non-empty block + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + */ + protected function block(OutputBlock $block) + { + if (empty($block->lines) && empty($block->children)) { + return; + } + + $this->currentBlock = $block; + + $pre = $this->indentStr(); + + if (! empty($block->selectors)) { + $this->blockSelectors($block); + + $this->indentLevel++; + } + + if (! empty($block->lines)) { + $this->blockLines($block); + } + + if (! empty($block->children)) { + $this->blockChildren($block); + } + + if (! empty($block->selectors)) { + $this->indentLevel--; + + if (empty($block->children)) { + $this->write($this->break); + } + + $this->write($pre . $this->close . $this->break); + } + } + + /** + * Entry point to formatting a block + * + * @api + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree + * @param \Leafo\ScssPhp\SourceMap\SourceMapGenerator|null $sourceMapGenerator Optional source map generator + * + * @return string + */ + public function format(OutputBlock $block, SourceMapGenerator $sourceMapGenerator = null) + { + $this->sourceMapGenerator = null; + + if ($sourceMapGenerator) { + $this->currentLine = 1; + $this->currentColumn = 0; + $this->sourceMapGenerator = $sourceMapGenerator; + } + + ob_start(); + + $this->block($block); + + $out = ob_get_clean(); + + return $out; + } + + /** + * @param string $str + */ + protected function write($str) + { + if ($this->sourceMapGenerator) { + $this->sourceMapGenerator->addMapping( + $this->currentLine, + $this->currentColumn, + $this->currentBlock->sourceLine, + $this->currentBlock->sourceColumn - 1, //columns from parser are off by one + $this->currentBlock->sourceName + ); + + $lines = explode("\n", $str); + $lineCount = count($lines); + $this->currentLine += $lineCount-1; + + $lastLine = array_pop($lines); + + $this->currentColumn = ($lineCount === 1 ? $this->currentColumn : 0) + strlen($lastLine); + } + + echo $str; + } +} diff --git a/inc/scssphp--old/src/Formatter/Compact.php b/inc/scssphp--old/src/Formatter/Compact.php new file mode 100644 index 0000000..4efa1a0 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Compact.php @@ -0,0 +1,45 @@ + + */ +class Compact extends Formatter +{ + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ''; + $this->break = ''; + $this->open = ' {'; + $this->close = "}\n\n"; + $this->tagSeparator = ','; + $this->assignSeparator = ':'; + $this->keepSemicolons = true; + } + + /** + * {@inheritdoc} + */ + public function indentStr() + { + return ' '; + } +} diff --git a/inc/scssphp--old/src/Formatter/Compressed.php b/inc/scssphp--old/src/Formatter/Compressed.php new file mode 100644 index 0000000..1faa7e1 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Compressed.php @@ -0,0 +1,62 @@ + + */ +class Compressed extends Formatter +{ + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ' '; + $this->break = ''; + $this->open = '{'; + $this->close = '}'; + $this->tagSeparator = ','; + $this->assignSeparator = ':'; + $this->keepSemicolons = false; + } + + /** + * {@inheritdoc} + */ + public function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + foreach ($block->lines as $index => $line) { + if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') { + unset($block->lines[$index]); + } elseif (substr($line, 0, 3) === '/*!') { + $block->lines[$index] = '/*' . substr($line, 3); + } + } + + $this->write($inner . implode($glue, $block->lines)); + + if (! empty($block->children)) { + $this->write($this->break); + } + } +} diff --git a/inc/scssphp--old/src/Formatter/Crunched.php b/inc/scssphp--old/src/Formatter/Crunched.php new file mode 100644 index 0000000..42d77b5 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Crunched.php @@ -0,0 +1,60 @@ + + */ +class Crunched extends Formatter +{ + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ' '; + $this->break = ''; + $this->open = '{'; + $this->close = '}'; + $this->tagSeparator = ','; + $this->assignSeparator = ':'; + $this->keepSemicolons = false; + } + + /** + * {@inheritdoc} + */ + public function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + foreach ($block->lines as $index => $line) { + if (substr($line, 0, 2) === '/*') { + unset($block->lines[$index]); + } + } + + $this->write($inner . implode($glue, $block->lines)); + + if (! empty($block->children)) { + $this->write($this->break); + } + } +} diff --git a/inc/scssphp--old/src/Formatter/Debug.php b/inc/scssphp--old/src/Formatter/Debug.php new file mode 100644 index 0000000..bfcbf41 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Debug.php @@ -0,0 +1,121 @@ + + */ +class Debug extends Formatter +{ + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ''; + $this->break = "\n"; + $this->open = ' {'; + $this->close = ' }'; + $this->tagSeparator = ', '; + $this->assignSeparator = ': '; + $this->keepSemicolons = true; + } + + /** + * {@inheritdoc} + */ + protected function indentStr() + { + return str_repeat(' ', $this->indentLevel); + } + + /** + * {@inheritdoc} + */ + protected function blockLines(OutputBlock $block) + { + $indent = $this->indentStr(); + + if (empty($block->lines)) { + $this->write("{$indent}block->lines: []\n"); + + return; + } + + foreach ($block->lines as $index => $line) { + $this->write("{$indent}block->lines[{$index}]: $line\n"); + } + } + + /** + * {@inheritdoc} + */ + protected function blockSelectors(OutputBlock $block) + { + $indent = $this->indentStr(); + + if (empty($block->selectors)) { + $this->write("{$indent}block->selectors: []\n"); + + return; + } + + foreach ($block->selectors as $index => $selector) { + $this->write("{$indent}block->selectors[{$index}]: $selector\n"); + } + } + + /** + * {@inheritdoc} + */ + protected function blockChildren(OutputBlock $block) + { + $indent = $this->indentStr(); + + if (empty($block->children)) { + $this->write("{$indent}block->children: []\n"); + + return; + } + + $this->indentLevel++; + + foreach ($block->children as $i => $child) { + $this->block($child); + } + + $this->indentLevel--; + } + + /** + * {@inheritdoc} + */ + protected function block(OutputBlock $block) + { + $indent = $this->indentStr(); + + $this->write("{$indent}block->type: {$block->type}\n" . + "{$indent}block->depth: {$block->depth}\n"); + + $this->currentBlock = $block; + + $this->blockSelectors($block); + $this->blockLines($block); + $this->blockChildren($block); + } +} diff --git a/inc/scssphp--old/src/Formatter/Expanded.php b/inc/scssphp--old/src/Formatter/Expanded.php new file mode 100644 index 0000000..d8c1e88 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Expanded.php @@ -0,0 +1,68 @@ + + */ +class Expanded extends Formatter +{ + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ' '; + $this->break = "\n"; + $this->open = ' {'; + $this->close = '}'; + $this->tagSeparator = ', '; + $this->assignSeparator = ': '; + $this->keepSemicolons = true; + } + + /** + * {@inheritdoc} + */ + protected function indentStr() + { + return str_repeat($this->indentChar, $this->indentLevel); + } + + /** + * {@inheritdoc} + */ + protected function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + foreach ($block->lines as $index => $line) { + if (substr($line, 0, 2) === '/*') { + $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); + } + } + + $this->write($inner . implode($glue, $block->lines)); + + if (empty($block->selectors) || ! empty($block->children)) { + $this->write($this->break); + } + } +} diff --git a/inc/scssphp--old/src/Formatter/Nested.php b/inc/scssphp--old/src/Formatter/Nested.php new file mode 100644 index 0000000..8f72206 --- /dev/null +++ b/inc/scssphp--old/src/Formatter/Nested.php @@ -0,0 +1,201 @@ + + */ +class Nested extends Formatter +{ + /** + * @var integer + */ + private $depth; + + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ' '; + $this->break = "\n"; + $this->open = ' {'; + $this->close = ' }'; + $this->tagSeparator = ', '; + $this->assignSeparator = ': '; + $this->keepSemicolons = true; + } + + /** + * {@inheritdoc} + */ + protected function indentStr() + { + $n = $this->depth - 1; + + return str_repeat($this->indentChar, max($this->indentLevel + $n, 0)); + } + + /** + * {@inheritdoc} + */ + protected function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + foreach ($block->lines as $index => $line) { + if (substr($line, 0, 2) === '/*') { + $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); + } + } + + $this->write($inner . implode($glue, $block->lines)); + + if (! empty($block->children)) { + $this->write($this->break); + } + } + + /** + * {@inheritdoc} + */ + protected function blockSelectors(OutputBlock $block) + { + $inner = $this->indentStr(); + + $this->write($inner + . implode($this->tagSeparator, $block->selectors) + . $this->open . $this->break); + } + + /** + * {@inheritdoc} + */ + protected function blockChildren(OutputBlock $block) + { + foreach ($block->children as $i => $child) { + $this->block($child); + + if ($i < count($block->children) - 1) { + $this->write($this->break); + + if (isset($block->children[$i + 1])) { + $next = $block->children[$i + 1]; + + if ($next->depth === max($block->depth, 1) && $child->depth >= $next->depth) { + $this->write($this->break); + } + } + } + } + } + + /** + * {@inheritdoc} + */ + protected function block(OutputBlock $block) + { + if ($block->type === 'root') { + $this->adjustAllChildren($block); + } + + if (empty($block->lines) && empty($block->children)) { + return; + } + + $this->currentBlock = $block; + + + $this->depth = $block->depth; + + if (! empty($block->selectors)) { + $this->blockSelectors($block); + + $this->indentLevel++; + } + + if (! empty($block->lines)) { + $this->blockLines($block); + } + + if (! empty($block->children)) { + $this->blockChildren($block); + } + + if (! empty($block->selectors)) { + $this->indentLevel--; + + $this->write($this->close); + } + + if ($block->type === 'root') { + $this->write($this->break); + } + } + + /** + * Adjust the depths of all children, depth first + * + * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + */ + private function adjustAllChildren(OutputBlock $block) + { + // flatten empty nested blocks + $children = []; + + foreach ($block->children as $i => $child) { + if (empty($child->lines) && empty($child->children)) { + if (isset($block->children[$i + 1])) { + $block->children[$i + 1]->depth = $child->depth; + } + + continue; + } + + $children[] = $child; + } + + $count = count($children); + + for ($i = 0; $i < $count; $i++) { + $depth = $children[$i]->depth; + $j = $i + 1; + + if (isset($children[$j]) && $depth < $children[$j]->depth) { + $childDepth = $children[$j]->depth; + + for (; $j < $count; $j++) { + if ($depth < $children[$j]->depth && $childDepth >= $children[$j]->depth) { + $children[$j]->depth = $depth + 1; + } + } + } + } + + $block->children = $children; + + // make relative to parent + foreach ($block->children as $child) { + $this->adjustAllChildren($child); + + $child->depth = $child->depth - $block->depth; + } + } +} diff --git a/inc/scssphp--old/src/Formatter/OutputBlock.php b/inc/scssphp--old/src/Formatter/OutputBlock.php new file mode 100644 index 0000000..5eb589c --- /dev/null +++ b/inc/scssphp--old/src/Formatter/OutputBlock.php @@ -0,0 +1,65 @@ + + */ +class OutputBlock +{ + /** + * @var string + */ + public $type; + + /** + * @var integer + */ + public $depth; + + /** + * @var array + */ + public $selectors; + + /** + * @var array + */ + public $lines; + + /** + * @var array + */ + public $children; + + /** + * @var \Leafo\ScssPhp\Formatter\OutputBlock + */ + public $parent; + + /** + * @var string + */ + public $sourceName; + + /** + * @var integer + */ + public $sourceLine; + + /** + * @var integer + */ + public $sourceColumn; +} diff --git a/inc/scssphp--old/src/Node.php b/inc/scssphp--old/src/Node.php new file mode 100644 index 0000000..b9f7945 --- /dev/null +++ b/inc/scssphp--old/src/Node.php @@ -0,0 +1,40 @@ + + */ +abstract class Node +{ + /** + * @var string + */ + public $type; + + /** + * @var integer + */ + public $sourceIndex; + + /** + * @var integer + */ + public $sourceLine; + + /** + * @var integer + */ + public $sourceColumn; +} diff --git a/inc/scssphp--old/src/Node/Number.php b/inc/scssphp--old/src/Node/Number.php new file mode 100644 index 0000000..42c1680 --- /dev/null +++ b/inc/scssphp--old/src/Node/Number.php @@ -0,0 +1,330 @@ + + */ +class Number extends Node implements \ArrayAccess +{ + /** + * @var integer + */ + static public $precision = 10; + + /** + * @see http://www.w3.org/TR/2012/WD-css3-values-20120308/ + * + * @var array + */ + static protected $unitTable = [ + 'in' => [ + 'in' => 1, + 'pc' => 6, + 'pt' => 72, + 'px' => 96, + 'cm' => 2.54, + 'mm' => 25.4, + 'q' => 101.6, + ], + 'turn' => [ + 'deg' => 360, + 'grad' => 400, + 'rad' => 6.28318530717958647692528676, // 2 * M_PI + 'turn' => 1, + ], + 's' => [ + 's' => 1, + 'ms' => 1000, + ], + 'Hz' => [ + 'Hz' => 1, + 'kHz' => 0.001, + ], + 'dpi' => [ + 'dpi' => 1, + 'dpcm' => 2.54, + 'dppx' => 96, + ], + ]; + + /** + * @var integer|float + */ + public $dimension; + + /** + * @var array + */ + public $units; + + /** + * Initialize number + * + * @param mixed $dimension + * @param mixed $initialUnit + */ + public function __construct($dimension, $initialUnit) + { + $this->type = Type::T_NUMBER; + $this->dimension = $dimension; + $this->units = is_array($initialUnit) + ? $initialUnit + : ($initialUnit ? [$initialUnit => 1] + : []); + } + + /** + * Coerce number to target units + * + * @param array $units + * + * @return \Leafo\ScssPhp\Node\Number + */ + public function coerce($units) + { + if ($this->unitless()) { + return new Number($this->dimension, $units); + } + + $dimension = $this->dimension; + + foreach (static::$unitTable['in'] as $unit => $conv) { + $from = isset($this->units[$unit]) ? $this->units[$unit] : 0; + $to = isset($units[$unit]) ? $units[$unit] : 0; + $factor = pow($conv, $from - $to); + $dimension /= $factor; + } + + return new Number($dimension, $units); + } + + /** + * Normalize number + * + * @return \Leafo\ScssPhp\Node\Number + */ + public function normalize() + { + $dimension = $this->dimension; + $units = []; + + $this->normalizeUnits($dimension, $units, 'in'); + + return new Number($dimension, $units); + } + + /** + * {@inheritdoc} + */ + public function offsetExists($offset) + { + if ($offset === -3) { + return $this->sourceColumn !== null; + } + + if ($offset === -2) { + return $this->sourceLine !== null; + } + + if ($offset === -1 + || $offset === 0 + || $offset === 1 + || $offset === 2 + ) { + return true; + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function offsetGet($offset) + { + switch ($offset) { + case -3: + return $this->sourceColumn; + + case -2: + return $this->sourceLine; + + case -1: + return $this->sourceIndex; + + case 0: + return $this->type; + + case 1: + return $this->dimension; + + case 2: + return $this->units; + } + } + + /** + * {@inheritdoc} + */ + public function offsetSet($offset, $value) + { + if ($offset === 1) { + $this->dimension = $value; + } elseif ($offset === 2) { + $this->units = $value; + } elseif ($offset == -1) { + $this->sourceIndex = $value; + } elseif ($offset == -2) { + $this->sourceLine = $value; + } elseif ($offset == -3) { + $this->sourceColumn = $value; + } + } + + /** + * {@inheritdoc} + */ + public function offsetUnset($offset) + { + if ($offset === 1) { + $this->dimension = null; + } elseif ($offset === 2) { + $this->units = null; + } elseif ($offset === -1) { + $this->sourceIndex = null; + } elseif ($offset === -2) { + $this->sourceLine = null; + } elseif ($offset === -3) { + $this->sourceColumn = null; + } + } + + /** + * Returns true if the number is unitless + * + * @return boolean + */ + public function unitless() + { + return ! array_sum($this->units); + } + + /** + * Returns unit(s) as the product of numerator units divided by the product of denominator units + * + * @return string + */ + public function unitStr() + { + $numerators = []; + $denominators = []; + + foreach ($this->units as $unit => $unitSize) { + if ($unitSize > 0) { + $numerators = array_pad($numerators, count($numerators) + $unitSize, $unit); + continue; + } + + if ($unitSize < 0) { + $denominators = array_pad($denominators, count($denominators) + $unitSize, $unit); + continue; + } + } + + return implode('*', $numerators) . (count($denominators) ? '/' . implode('*', $denominators) : ''); + } + + /** + * Output number + * + * @param \Leafo\ScssPhp\Compiler $compiler + * + * @return string + */ + public function output(Compiler $compiler = null) + { + $dimension = round($this->dimension, static::$precision); + + $units = array_filter($this->units, function ($unitSize) { + return $unitSize; + }); + + if (count($units) > 1 && array_sum($units) === 0) { + $dimension = $this->dimension; + $units = []; + + $this->normalizeUnits($dimension, $units, 'in'); + + $dimension = round($dimension, static::$precision); + $units = array_filter($units, function ($unitSize) { + return $unitSize; + }); + } + + $unitSize = array_sum($units); + + if ($compiler && ($unitSize > 1 || $unitSize < 0 || count($units) > 1)) { + $compiler->throwError((string) $dimension . $this->unitStr() . " isn't a valid CSS value."); + } + + reset($units); + $unit = key($units); + $dimension = number_format($dimension, static::$precision, '.', ''); + + return (static::$precision ? rtrim(rtrim($dimension, '0'), '.') : $dimension) . $unit; + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->output(); + } + + /** + * Normalize units + * + * @param integer|float $dimension + * @param array $units + * @param string $baseUnit + */ + private function normalizeUnits(&$dimension, &$units, $baseUnit = 'in') + { + $dimension = $this->dimension; + $units = []; + + foreach ($this->units as $unit => $exp) { + if (isset(static::$unitTable[$baseUnit][$unit])) { + $factor = pow(static::$unitTable[$baseUnit][$unit], $exp); + + $unit = $baseUnit; + $dimension /= $factor; + } + + $units[$unit] = $exp + (isset($units[$unit]) ? $units[$unit] : 0); + } + } +} diff --git a/inc/scssphp--old/src/Parser.php b/inc/scssphp--old/src/Parser.php new file mode 100644 index 0000000..6fdea3e --- /dev/null +++ b/inc/scssphp--old/src/Parser.php @@ -0,0 +1,2494 @@ + + */ +class Parser +{ + const SOURCE_INDEX = -1; + const SOURCE_LINE = -2; + const SOURCE_COLUMN = -3; + + /** + * @var array + */ + protected static $precedence = [ + '=' => 0, + 'or' => 1, + 'and' => 2, + '==' => 3, + '!=' => 3, + '<=>' => 3, + '<=' => 4, + '>=' => 4, + '<' => 4, + '>' => 4, + '+' => 5, + '-' => 5, + '*' => 6, + '/' => 6, + '%' => 6, + ]; + + protected static $commentPattern; + protected static $operatorPattern; + protected static $whitePattern; + + private $sourceName; + private $sourceIndex; + private $sourcePositions; + private $charset; + private $count; + private $env; + private $inParens; + private $eatWhiteDefault; + private $buffer; + private $utf8; + private $encoding; + private $patternModifiers; + + /** + * Constructor + * + * @api + * + * @param string $sourceName + * @param integer $sourceIndex + * @param string $encoding + */ + public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8') + { + $this->sourceName = $sourceName ?: '(stdin)'; + $this->sourceIndex = $sourceIndex; + $this->charset = null; + $this->utf8 = ! $encoding || strtolower($encoding) === 'utf-8'; + $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; + + if (empty(static::$operatorPattern)) { + static::$operatorPattern = '([*\/%+-]|[!=]\=|\>\=?|\<\=\>|\<\=?|and|or)'; + + $commentSingle = '\/\/'; + $commentMultiLeft = '\/\*'; + $commentMultiRight = '\*\/'; + + static::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; + static::$whitePattern = $this->utf8 + ? '/' . $commentSingle . '[^\n]*\s*|(' . static::$commentPattern . ')\s*|\s+/AisuS' + : '/' . $commentSingle . '[^\n]*\s*|(' . static::$commentPattern . ')\s*|\s+/AisS'; + } + } + + /** + * Get source file name + * + * @api + * + * @return string + */ + public function getSourceName() + { + return $this->sourceName; + } + + /** + * Throw parser error + * + * @api + * + * @param string $msg + * + * @throws \Leafo\ScssPhp\Exception\ParserException + */ + public function throwParseError($msg = 'parse error') + { + list($line, /* $column */) = $this->getSourcePosition($this->count); + + $loc = empty($this->sourceName) ? "line: $line" : "$this->sourceName on line $line"; + + if ($this->peek("(.*?)(\n|$)", $m, $this->count)) { + throw new ParserException("$msg: failed at `$m[1]` $loc"); + } + + throw new ParserException("$msg: $loc"); + } + + /** + * Parser buffer + * + * @api + * + * @param string $buffer + * + * @return \Leafo\ScssPhp\Block + */ + public function parse($buffer) + { + // strip BOM (byte order marker) + if (substr($buffer, 0, 3) === "\xef\xbb\xbf") { + $buffer = substr($buffer, 3); + } + + $this->buffer = rtrim($buffer, "\x00..\x1f"); + $this->count = 0; + $this->env = null; + $this->inParens = false; + $this->eatWhiteDefault = true; + + $this->saveEncoding(); + $this->extractLineNumbers($buffer); + + $this->pushBlock(null); // root block + $this->whitespace(); + $this->pushBlock(null); + $this->popBlock(); + + while ($this->parseChunk()) { + ; + } + + if ($this->count !== strlen($this->buffer)) { + $this->throwParseError(); + } + + if (! empty($this->env->parent)) { + $this->throwParseError('unclosed block'); + } + + if ($this->charset) { + array_unshift($this->env->children, $this->charset); + } + + $this->env->isRoot = true; + + $this->restoreEncoding(); + + return $this->env; + } + + /** + * Parse a value or value list + * + * @api + * + * @param string $buffer + * @param string $out + * + * @return boolean + */ + public function parseValue($buffer, &$out) + { + $this->count = 0; + $this->env = null; + $this->inParens = false; + $this->eatWhiteDefault = true; + $this->buffer = (string) $buffer; + + $this->saveEncoding(); + + $list = $this->valueList($out); + + $this->restoreEncoding(); + + return $list; + } + + /** + * Parse a selector or selector list + * + * @api + * + * @param string $buffer + * @param string $out + * + * @return boolean + */ + public function parseSelector($buffer, &$out) + { + $this->count = 0; + $this->env = null; + $this->inParens = false; + $this->eatWhiteDefault = true; + $this->buffer = (string) $buffer; + + $this->saveEncoding(); + + $selector = $this->selectors($out); + + $this->restoreEncoding(); + + return $selector; + } + + /** + * Parse a single chunk off the head of the buffer and append it to the + * current parse environment. + * + * Returns false when the buffer is empty, or when there is an error. + * + * This function is called repeatedly until the entire document is + * parsed. + * + * This parser is most similar to a recursive descent parser. Single + * functions represent discrete grammatical rules for the language, and + * they are able to capture the text that represents those rules. + * + * Consider the function Compiler::keyword(). (All parse functions are + * structured the same.) + * + * The function takes a single reference argument. When calling the + * function it will attempt to match a keyword on the head of the buffer. + * If it is successful, it will place the keyword in the referenced + * argument, advance the position in the buffer, and return true. If it + * fails then it won't advance the buffer and it will return false. + * + * All of these parse functions are powered by Compiler::match(), which behaves + * the same way, but takes a literal regular expression. Sometimes it is + * more convenient to use match instead of creating a new function. + * + * Because of the format of the functions, to parse an entire string of + * grammatical rules, you can chain them together using &&. + * + * But, if some of the rules in the chain succeed before one fails, then + * the buffer position will be left at an invalid state. In order to + * avoid this, Compiler::seek() is used to remember and set buffer positions. + * + * Before parsing a chain, use $s = $this->seek() to remember the current + * position into $s. Then if a chain fails, use $this->seek($s) to + * go back where we started. + * + * @return boolean + */ + protected function parseChunk() + { + $s = $this->seek(); + + // the directives + if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] === '@') { + if ($this->literal('@at-root') && + ($this->selectors($selector) || true) && + ($this->map($with) || true) && + $this->literal('{') + ) { + $atRoot = $this->pushSpecialBlock(Type::T_AT_ROOT, $s); + $atRoot->selector = $selector; + $atRoot->with = $with; + + return true; + } + + $this->seek($s); + + if ($this->literal('@media') && $this->mediaQueryList($mediaQueryList) && $this->literal('{')) { + $media = $this->pushSpecialBlock(Type::T_MEDIA, $s); + $media->queryList = $mediaQueryList[2]; + + return true; + } + + $this->seek($s); + + if ($this->literal('@mixin') && + $this->keyword($mixinName) && + ($this->argumentDef($args) || true) && + $this->literal('{') + ) { + $mixin = $this->pushSpecialBlock(Type::T_MIXIN, $s); + $mixin->name = $mixinName; + $mixin->args = $args; + + return true; + } + + $this->seek($s); + + if ($this->literal('@include') && + $this->keyword($mixinName) && + ($this->literal('(') && + ($this->argValues($argValues) || true) && + $this->literal(')') || true) && + ($this->end() || + $this->literal('{') && $hasBlock = true) + ) { + $child = [Type::T_INCLUDE, $mixinName, isset($argValues) ? $argValues : null, null]; + + if (! empty($hasBlock)) { + $include = $this->pushSpecialBlock(Type::T_INCLUDE, $s); + $include->child = $child; + } else { + $this->append($child, $s); + } + + return true; + } + + $this->seek($s); + + if ($this->literal('@scssphp-import-once') && + $this->valueList($importPath) && + $this->end() + ) { + $this->append([Type::T_SCSSPHP_IMPORT_ONCE, $importPath], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@import') && + $this->valueList($importPath) && + $this->end() + ) { + $this->append([Type::T_IMPORT, $importPath], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@import') && + $this->url($importPath) && + $this->end() + ) { + $this->append([Type::T_IMPORT, $importPath], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@extend') && + $this->selectors($selectors) && + $this->end() + ) { + // check for '!flag' + $optional = $this->stripOptionalFlag($selectors); + $this->append([Type::T_EXTEND, $selectors, $optional], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@function') && + $this->keyword($fnName) && + $this->argumentDef($args) && + $this->literal('{') + ) { + $func = $this->pushSpecialBlock(Type::T_FUNCTION, $s); + $func->name = $fnName; + $func->args = $args; + + return true; + } + + $this->seek($s); + + if ($this->literal('@break') && $this->end()) { + $this->append([Type::T_BREAK], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@continue') && $this->end()) { + $this->append([Type::T_CONTINUE], $s); + + return true; + } + + $this->seek($s); + + + if ($this->literal('@return') && ($this->valueList($retVal) || true) && $this->end()) { + $this->append([Type::T_RETURN, isset($retVal) ? $retVal : [Type::T_NULL]], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@each') && + $this->genericList($varNames, 'variable', ',', false) && + $this->literal('in') && + $this->valueList($list) && + $this->literal('{') + ) { + $each = $this->pushSpecialBlock(Type::T_EACH, $s); + + foreach ($varNames[2] as $varName) { + $each->vars[] = $varName[1]; + } + + $each->list = $list; + + return true; + } + + $this->seek($s); + + if ($this->literal('@while') && + $this->expression($cond) && + $this->literal('{') + ) { + $while = $this->pushSpecialBlock(Type::T_WHILE, $s); + $while->cond = $cond; + + return true; + } + + $this->seek($s); + + if ($this->literal('@for') && + $this->variable($varName) && + $this->literal('from') && + $this->expression($start) && + ($this->literal('through') || + ($forUntil = true && $this->literal('to'))) && + $this->expression($end) && + $this->literal('{') + ) { + $for = $this->pushSpecialBlock(Type::T_FOR, $s); + $for->var = $varName[1]; + $for->start = $start; + $for->end = $end; + $for->until = isset($forUntil); + + return true; + } + + $this->seek($s); + + if ($this->literal('@if') && $this->valueList($cond) && $this->literal('{')) { + $if = $this->pushSpecialBlock(Type::T_IF, $s); + $if->cond = $cond; + $if->cases = []; + + return true; + } + + $this->seek($s); + + if ($this->literal('@debug') && + $this->valueList($value) && + $this->end() + ) { + $this->append([Type::T_DEBUG, $value], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@warn') && + $this->valueList($value) && + $this->end() + ) { + $this->append([Type::T_WARN, $value], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@error') && + $this->valueList($value) && + $this->end() + ) { + $this->append([Type::T_ERROR, $value], $s); + + return true; + } + + $this->seek($s); + + if ($this->literal('@content') && $this->end()) { + $this->append([Type::T_MIXIN_CONTENT], $s); + + return true; + } + + $this->seek($s); + + $last = $this->last(); + + if (isset($last) && $last[0] === Type::T_IF) { + list(, $if) = $last; + + if ($this->literal('@else')) { + if ($this->literal('{')) { + $else = $this->pushSpecialBlock(Type::T_ELSE, $s); + } elseif ($this->literal('if') && $this->valueList($cond) && $this->literal('{')) { + $else = $this->pushSpecialBlock(Type::T_ELSEIF, $s); + $else->cond = $cond; + } + + if (isset($else)) { + $else->dontAppend = true; + $if->cases[] = $else; + + return true; + } + } + + $this->seek($s); + } + + // only retain the first @charset directive encountered + if ($this->literal('@charset') && + $this->valueList($charset) && + $this->end() + ) { + if (! isset($this->charset)) { + $statement = [Type::T_CHARSET, $charset]; + + list($line, $column) = $this->getSourcePosition($s); + + $statement[static::SOURCE_LINE] = $line; + $statement[static::SOURCE_COLUMN] = $column; + $statement[static::SOURCE_INDEX] = $this->sourceIndex; + + $this->charset = $statement; + } + + return true; + } + + $this->seek($s); + + // doesn't match built in directive, do generic one + if ($this->literal('@', false) && + $this->keyword($dirName) && + ($this->variable($dirValue) || $this->openString('{', $dirValue) || true) && + $this->literal('{') + ) { + if ($dirName === 'media') { + $directive = $this->pushSpecialBlock(Type::T_MEDIA, $s); + } else { + $directive = $this->pushSpecialBlock(Type::T_DIRECTIVE, $s); + $directive->name = $dirName; + } + + if (isset($dirValue)) { + $directive->value = $dirValue; + } + + return true; + } + + $this->seek($s); + + return false; + } + + // property shortcut + // captures most properties before having to parse a selector + if ($this->keyword($name, false) && + $this->literal(': ') && + $this->valueList($value) && + $this->end() + ) { + $name = [Type::T_STRING, '', [$name]]; + $this->append([Type::T_ASSIGN, $name, $value], $s); + + return true; + } + + $this->seek($s); + + // variable assigns + if ($this->variable($name) && + $this->literal(':') && + $this->valueList($value) && + $this->end() + ) { + // check for '!flag' + $assignmentFlags = $this->stripAssignmentFlags($value); + $this->append([Type::T_ASSIGN, $name, $value, $assignmentFlags], $s); + + return true; + } + + $this->seek($s); + + // misc + if ($this->literal('-->')) { + return true; + } + + // opening css block + if ($this->selectors($selectors) && $this->literal('{')) { + $this->pushBlock($selectors, $s); + + return true; + } + + $this->seek($s); + + // property assign, or nested assign + if ($this->propertyName($name) && $this->literal(':')) { + $foundSomething = false; + + if ($this->valueList($value)) { + $this->append([Type::T_ASSIGN, $name, $value], $s); + $foundSomething = true; + } + + if ($this->literal('{')) { + $propBlock = $this->pushSpecialBlock(Type::T_NESTED_PROPERTY, $s); + $propBlock->prefix = $name; + $foundSomething = true; + } elseif ($foundSomething) { + $foundSomething = $this->end(); + } + + if ($foundSomething) { + return true; + } + } + + $this->seek($s); + + // closing a block + if ($this->literal('}')) { + $block = $this->popBlock(); + + if (isset($block->type) && $block->type === Type::T_INCLUDE) { + $include = $block->child; + unset($block->child); + $include[3] = $block; + $this->append($include, $s); + } elseif (empty($block->dontAppend)) { + $type = isset($block->type) ? $block->type : Type::T_BLOCK; + $this->append([$type, $block], $s); + } + + return true; + } + + // extra stuff + if ($this->literal(';') || + $this->literal(' + + + + + +
    +0.5?-1:1);var r=o*(Math.random()>0.5?-1:1);document.body.style.marginLeft=q+"px";document.body.style.marginTop=r+"px";setTimeout(function(){document.body.style.marginLeft="";document.body.style.marginTop=""},75)}}m.colorful=false;function i(){requestAnimationFrame(i);c.clearRect(0,0,b.width,b.height);for(var n=0;nparseInt(f.height)){o.overflowY="scroll"}}else{o.overflow="hidden"}i.textContent=k.value.substring(0,m);if(k.nodeName==="INPUT"){i.textContent=i.textContent.replace(/\s/g,"\u00a0")}var n=document.createElement("span");n.textContent=k.value.substring(m)||".";i.appendChild(n);var g={top:n.offsetTop+parseInt(f.borderTopWidth),left:n.offsetLeft+parseInt(f.borderLeftWidth)};if(h){n.style.backgroundColor="#aaa"}else{document.body.removeChild(i)}return g}if(typeof b!="undefined"&&typeof b.exports!="undefined"){b.exports=c}else{window.getCaretCoordinates=c}}())}])}); \ No newline at end of file diff --git a/js/login.js b/js/login.js new file mode 100644 index 0000000..809b7b0 --- /dev/null +++ b/js/login.js @@ -0,0 +1,73 @@ +/* + * Resize Image +*/ +function resizeImage(id) { + jQuery('#' + id).css({ + 'position': 'absolute', + 'top': '0px', + 'left': '0px', + 'width': '100%', + 'height': '100%', + 'z-index': -1, + 'overflow': 'hidden' + }); + var w = jQuery(window).width(), + h = jQuery(window).height(), + o = jQuery('#' + id).children('img'), + iW = o.width(), + iH = o.height(); + o.css({ + 'display': 'block', + 'opacity': 0 + }); + if (w > h) { + if (iW > iH) { + o.css({ + 'width': w + }); + o.css({ + 'height': Math.round((iH / iW) * w) + }); + var newIh = Math.round((iH / iW) * w); + if (newIh < h) { + o.css({ + 'height': h + }); + o.css({ + 'width': Math.round((iW / iH) * h) + }) + } + } else { + o.css({ + 'height': h + }); + o.css({ + 'width': Math.round((iW / iH) * h) + }) + } + } else { + o.css({ + 'height': h + }); + o.css({ + 'width': Math.round((iW / iH) * h) + }) + } + var newIW = o.width(), + newIH = o.height(); + if (newIW > w) { + var l = (newIW - w) / 2; + o.css('margin-left', -l) + } else { + o.css('margin-left', 0) + } + if (newIH > h) { + var t = (newIH - h) / 2; + o.css('margin-top', -t) + } else { + o.css('margin-top', 0) + } + o.css({ + 'opacity': '1' + }) +} \ No newline at end of file diff --git a/js/sakura-app.js b/js/sakura-app.js new file mode 100644 index 0000000..2a49aac --- /dev/null +++ b/js/sakura-app.js @@ -0,0 +1,137 @@ +/*! + * Sakura application bundle + * @author Mashiro + * @url https://2heng.xin + * @date 2018.5.25 + */ + +mashiro_global.variables=new function(){this.has_bot_ui=false;this.isNight=false;this.skinSecter=false;} +mashiro_global.ini=new function(){this.normalize=function(){lazyload();mashiro_global.post_list_show_animation.ini();} +this.pjax=function(){pjaxInit();mashiro_global.post_list_show_animation.ini();}} +function setCookie(name,value,days){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toUTCString();} +document.cookie=name+mashiro_option.cookie_version_control+"="+(value||"")+expires+"; path=/";} +function getCookie(name){var nameEQ=name+mashiro_option.cookie_version_control+"=";var ca=document.cookie.split(';');for(var i=0;i=article_height) +$("article.post-list-thumb").eq(i).addClass('post-list-show');$(window).scroll(function(){var scrolltop=$(window).scrollTop();if(scrolltop+window_height>=article_height&&scrolltop) +$("article.post-list-thumb").eq(i).addClass("post-list-show");});});}} +mashiro_global.font_control=new function(){this.change_font=function(){if($("body").hasClass("serif")){$("body").removeClass("serif");$(".control-btn-serif").removeClass("selected");$(".control-btn-sans-serif").addClass("selected");setCookie("font_family","sans-serif",30);}else{$("body").addClass("serif");$(".control-btn-serif").addClass("selected");$(".control-btn-sans-serif").removeClass("selected");setCookie("font_family","serif",30);if(document.body.clientWidth<=860){addComment.createButterbar("将从网络加载字体,流量请注意");}}} +this.ini=function(){if(document.body.clientWidth>860){if(!getCookie("font_family")||getCookie("font_family")=="serif") +$("body").addClass("serif");} +if(getCookie("font_family")=="sans-serif"){$("body").removeClass("sans-serif");$(".control-btn-serif").removeClass("selected");$(".control-btn-sans-serif").addClass("selected");}}} +mashiro_global.font_control.ini();function code_highlight_style(){function gen_top_bar(i){var attributes={'autocomplete':'off','autocorrect':'off','autocapitalize':'off','spellcheck':'false','contenteditable':'false','design':'by Mashiro'} +var ele_name=$('pre:eq('+i+')')[0].children[0].className;var lang=ele_name.substr(0,ele_name.indexOf(" ")).replace('language-','');if(lang.toLowerCase()=="hljs")var lang="text";$('pre:eq('+i+')').addClass('highlight-wrap');for(var t in attributes){$('pre:eq('+i+')').attr(t,attributes[t]);} +$('pre:eq('+i+') code').attr('data-rel',lang.toUpperCase());} +$('pre code').each(function(i,block){hljs.highlightBlock(block);});for(var i=0;i<$('pre').length;i++){gen_top_bar(i);} +hljs.initLineNumbersOnLoad();$('pre').on('click',function(e){if(e.target!==this)return;$(this).toggleClass('code-block-fullscreen');$('html').toggleClass('code-block-fullscreen-html-scroll');});} +try{code_highlight_style();}catch(e){} +function attach_image(){$('#upload-img-file').change(function(){if(this.files.length>10){addComment.createButterbar("每次上传上限为10张.
    10 files max per request.");return 0;} +for(i=0;i=5242880){alert('图片上传大小限制为5 MB.\n5 MB max per file.\n\n「'+this.files[i].name+'」\n\n这张图太大啦~\nThis image is too large~');}} +for(var i=0;i
    ',o.onload=function(){var n=document.querySelector("#baguette-img-"+t+" .spinner");i.removeChild(n),!I.async&&e&&e()},o.setAttribute("src",imageSrc),i.appendChild(o),I.captions&&imageCaption&&(a.innerHTML=imageCaption,i.appendChild(a)),I.async&&e&&e()}} +function l(t){var e=imageElement.href;if(t.dataset){var n=[];for(var i in t.dataset)"at-"!==i.substring(0,3)||isNaN(i.substring(3))||(n[i.replace("at-","")]=t.dataset[i]);keys=Object.keys(n).sort(function(t,e){return parseInt(t)=1?(L--,d(),h(L),t=!0):I.animation&&(k.className="bounce-from-left",setTimeout(function(){k.className=""},400),t=!1),I.onChange&&I.onChange(L,X.length),t} +function d(){var t=100*-L+"%";"fadeIn"===I.animation?(k.style.opacity=0,setTimeout(function(){H.transforms?k.style.transform=k.style.webkitTransform="translate3d("+t+",0,0)":k.style.left=t,k.style.opacity=1},400)):H.transforms?k.style.transform=k.style.webkitTransform="translate3d("+t+",0,0)":k.style.left=t} +function f(){var t=y("div");return"undefined"!=typeof t.style.perspective||"undefined"!=typeof t.style.webkitPerspective} +function g(){var t=y("div");return t.innerHTML="","http://www.w3.org/2000/svg"==(t.firstChild&&t.firstChild.namespaceURI)} +function p(t){t-L>=I.preload||s(t+1,function(){p(t+1)})} +function h(t){L-t>=I.preload||s(t-1,function(){h(t-1)})} +function m(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)} +function v(t){return document.getElementById(t)} +function y(t){return document.createElement(t)} +var b,k,w,C,T,N,E='',x='',B='',I={},P={captions:!0,buttons:"auto",async:!1,preload:2,animation:"slideIn",afterShow:null,afterHide:null,onChange:null},H={},L=0,M=-1,S=!1,A=/.+\.(gif|jpe?g|png|webp)/i,j=[],D=[],X=[];return[].forEach||(Array.prototype.forEach=function(t,e){for(var n=0;n0){if($('.videolive').length>0){Siren.splay();}}},livepause:function(){if(s.oncanplay!=undefined&&$('.haslive').length>0){Siren.spause();$('.video-stu').css({"bottom":"0px"}).html('已暂停 ...');}},addsource:function(){$('.video-stu').html('正在载入视频 ...').css({"bottom":"0px"});var t=Poi.movies.name.split(","),_t=t[Math.floor(Math.random()*t.length)];$('#bgvideo').attr('src',Poi.movies.url+'/'+_t+'.mp4');$('#bgvideo').attr('video-name',_t);},LV:function(){var _btn=$('#video-btn');_btn.on('click',function(){if($(this).hasClass('loadvideo')){$(this).addClass('video-pause').removeClass('loadvideo').hide();Siren.addsource();s.oncanplay=function(){Siren.splay();$('#video-add').show();_btn.addClass('videolive');_btn.addClass('haslive');}}else{if($(this).hasClass('video-pause')){Siren.spause();_btn.removeClass('videolive');$('.video-stu').css({"bottom":"0px"}).html('已暂停 ...');}else{Siren.splay();_btn.addClass('videolive');}} +s.onended=function(){$('#bgvideo').attr('src','');$('#video-add').hide();_btn.addClass('loadvideo').removeClass('video-pause');_btn.removeClass('videolive');_btn.removeClass('haslive');$('.focusinfo').css({"top":"49.3%"});}});$('#video-add').on('click',function(){Siren.addsource();});},AH:function(){if(Poi.windowheight=='auto'){if($('h1.main-title').length>0){var _height=$(window).height();$('#centerbg').css({'height':_height});$('#bgvideo').css({'min-height':_height});$(window).resize(function(){Siren.AH();});}}else{$('.headertop').addClass('headertop-bar');}},PE:function(){if($('.headertop').length>0){if($('h1.main-title').length>0){$('.blank').css({"padding-top":"0px"});$('.headertop').css({"height":"auto"}).show();if(Poi.movies.live=='open')Siren.liveplay();}else{$('.blank').css({"padding-top":"75px"});$('.headertop').css({"height":"0px"}).hide();Siren.livepause();}}},CE:function(){$('.comments-hidden').show();$('.comments-main').hide();$('.comments-hidden').click(function(){$('.comments-main').slideDown(500);$('.comments-hidden').hide();});$('.archives').hide();$('.archives:first').show();$('#archives-temp h3').click(function(){$(this).next().slideToggle('fast');return false;});baguetteBox.run('.entry-content',{captions:function(element){return element.getElementsByTagName('img')[0].alt;}});$('.js-toggle-search').on('click',function(){$('.js-toggle-search').toggleClass('is-active');$('.js-search').toggleClass('is-visible');});$('.search_close').on('click',function(){if($('.js-search').hasClass('is-visible')){$('.js-toggle-search').toggleClass('is-active');$('.js-search').toggleClass('is-visible');}});$('#show-nav').on('click',function(){if($('#show-nav').hasClass('showNav')){$('#show-nav').removeClass('showNav').addClass('hideNav');$('.site-top .lower nav').addClass('navbar');}else{$('#show-nav').removeClass('hideNav').addClass('showNav');$('.site-top .lower nav').removeClass('navbar');}});$("#loading").click(function(){$("#loading").fadeOut(500);});},NH:function(){var h1=0,h2=50,ss=$(document).scrollTop();$(window).scroll(function(){var s=$(document).scrollTop();if(s==h1){$('.site-header').removeClass('yya');} +if(s>h1){$('.site-header').addClass('yya');} +if(s>h2){$('.site-header').addClass('gizle');if(s>ss){$('.site-header').removeClass('sabit');}else{$('.site-header').addClass('sabit');} +ss=s;}});},XLS:function(){$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');$('body').on('click','#pagination a',function(){$(this).addClass("loading").text("");$.ajax({type:"POST",url:$(this).attr("href")+"#main",success:function(data){result=$(data).find("#main .post");nextHref=$(data).find("#pagination a").attr("href");$("#main").append(result.fadeIn(500));$("#pagination a").removeClass("loading").text("Previous");lazyload();mashiro_global.post_list_show_animation.ini(50);if(nextHref!=undefined){$("#pagination a").attr("href",nextHref);}else{$("#pagination").html("很高兴你翻到这里,但是真的没有了...");}}});return false;});},XCS:function(){var __cancel=jQuery('#cancel-comment-reply-link'),__cancel_text=__cancel.text(),__list='commentwrap';jQuery(document).on("submit","#commentform",function(){jQuery.ajax({url:Poi.ajaxurl,data:jQuery(this).serialize()+"&action=ajax_comment",type:jQuery(this).attr('method'),beforeSend:addComment.createButterbar("提交中(Commiting)...."),error:function(request){var t=addComment;t.createButterbar(request.responseText);},success:function(data){jQuery('textarea').each(function(){this.value=''});var t=addComment,cancel=t.I('cancel-comment-reply-link'),temp=t.I('wp-temp-form-div'),respond=t.I(t.respondId),post=t.I('comment_post_ID').value,parent=t.I('comment_parent').value;if(parent!='0'){jQuery('#respond').before('
      '+data+'
    ');}else if(!jQuery('.'+__list).length){if(Poi.formpostion=='bottom'){jQuery('#respond').before('
      '+data+'
    ');}else{jQuery('#respond').after('
      '+data+'
    ');}}else{if(Poi.order=='asc'){jQuery('.'+__list).append(data);}else{jQuery('.'+__list).prepend(data);}} +t.createButterbar("提交成功(Succeed)");lazyload();code_highlight_style();click_to_view_image();clean_upload_images();cancel.style.display='none';cancel.onclick=null;t.I('comment_parent').value='0';if(temp&&respond){temp.parentNode.insertBefore(respond,temp);temp.parentNode.removeChild(temp)}}});return false;});addComment={moveForm:function(commId,parentId,respondId){var t=this,div,comm=t.I(commId),respond=t.I(respondId),cancel=t.I('cancel-comment-reply-link'),parent=t.I('comment_parent'),post=t.I('comment_post_ID');__cancel.text(__cancel_text);t.respondId=respondId;if(!t.I('wp-temp-form-div')){div=document.createElement('div');div.id='wp-temp-form-div';div.style.display='none';respond.parentNode.insertBefore(div,respond)}!comm?(temp=t.I('wp-temp-form-div'),t.I('comment_parent').value='0',temp.parentNode.insertBefore(respond,temp),temp.parentNode.removeChild(temp)):comm.parentNode.insertBefore(respond,comm.nextSibling);jQuery("body").animate({scrollTop:jQuery('#respond').offset().top-180},400);parent.value=parentId;cancel.style.display='';cancel.onclick=function(){var t=addComment,temp=t.I('wp-temp-form-div'),respond=t.I(t.respondId);t.I('comment_parent').value='0';if(temp&&respond){temp.parentNode.insertBefore(respond,temp);temp.parentNode.removeChild(temp);} +this.style.display='none';this.onclick=null;return false;};try{t.I('comment').focus();}catch(e){} +return false;},I:function(e){return document.getElementById(e);},clearButterbar:function(e){if(jQuery(".butterBar").length>0){jQuery(".butterBar").remove();}},createButterbar:function(message,showtime){var t=this;t.clearButterbar();jQuery("body").append('

    '+message+'

    ');if(showtime>0){setTimeout("jQuery('.butterBar').remove()",showtime);}else{setTimeout("jQuery('.butterBar').remove()",6000);}}};},XCP:function(){$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');$('body').on('click','#comments-navi a',function(e){e.preventDefault();$.ajax({type:"GET",url:$(this).attr('href'),beforeSend:function(){$('#comments-navi').remove();$('ul.commentwrap').remove();$('#loading-comments').slideDown();$body.animate({scrollTop:$('#comments-list-title').offset().top-65},800);},dataType:"html",success:function(out){result=$(out).find('ul.commentwrap');nextlink=$(out).find('#comments-navi');$('#loading-comments').slideUp('fast');$('#loading-comments').after(result.fadeIn(500));$('ul.commentwrap').after(nextlink);lazyload();code_highlight_style();click_to_view_image();}});});},IA:function(){POWERMODE.colorful=true;POWERMODE.shake=false;document.body.addEventListener('input',POWERMODE)},GT:function(){var offset=100,offset_opacity=1200,scroll_top_duration=700,$back_to_top=$('.cd-top');$(window).scroll(function(){if($(this).scrollTop()>offset){$back_to_top.addClass('cd-is-visible');$(".changeSkin-gear").css("bottom","0");if(screen.height>650){$(".cd-top.cd-is-visible").css("top","-326px");}else{$(".cd-top.cd-is-visible").css("top",(screen.height*0.9-900)+"px");}}else{$(".changeSkin-gear").css("bottom","-999px");$(".cd-top.cd-is-visible").css("top","-900px");$back_to_top.removeClass('cd-is-visible cd-fade-out');} +if($(this).scrollTop()>offset_opacity){$back_to_top.addClass('cd-fade-out');}});$back_to_top.on('click',function(event){event.preventDefault();$('body,html').animate({scrollTop:0,},scroll_top_duration);});}} +$(function(){Siren.AH();Siren.PE();Siren.NH();Siren.GT();Siren.XLS();Siren.XCS();Siren.XCP();Siren.CE();Siren.MN();Siren.IA();Siren.LV();if(Poi.pjax){$(document).pjax('a[target!=_top]','#page',{fragment:'#page',timeout:8000,}).on('pjax:send',function(){$("#bar").css("width","0%");if(mashiro_option.NProgressON)NProgress.start();Siren.MNH();}).on('pjax:complete',function(){Siren.AH();Siren.PE();Siren.CE();if(mashiro_option.NProgressON)NProgress.done();mashiro_global.ini.pjax();$("#loading").fadeOut(500);if(Poi.codelamp=='open'){self.Prism.highlightAll(event)};if($('.ds-thread').length>0){if(typeof DUOSHUO!=='undefined'){DUOSHUO.EmbedThread('.ds-thread');}else{$.getScript("//static.duoshuo.com/embed.js");}}}).on('submit','.search-form,.s-search',function(event){event.preventDefault();$.pjax.submit(event,'#page',{fragment:'#page',timeout:8000,});if($('.js-search.is-visible').length>0){$('.js-toggle-search').toggleClass('is-active');$('.js-search').toggleClass('is-visible');}});window.addEventListener('popstate',function(e){Siren.AH();Siren.PE();Siren.CE();timeSeriesReload(true);},false);} +$.fn.postLike=function(){if($(this).hasClass('done')){return false;}else{$(this).addClass('done');var id=$(this).data("id"),action=$(this).data('action'),rateHolder=$(this).children('.count');var ajax_data={action:"specs_zan",um_id:id,um_action:action};$.post(Poi.ajaxurl,ajax_data,function(data){$(rateHolder).html(data);});return false;}};$(document).on("click",".specsZan",function(){$(this).postLike();});console.log("%c Mashiro %c","background:#24272A; color:#ffffff","","https://2heng.xin/");console.log("%c Github %c","background:#24272A; color:#ffffff","","https://github.com/mashirozx");});var isWebkit=navigator.userAgent.toLowerCase().indexOf('webkit')>-1,isOpera=navigator.userAgent.toLowerCase().indexOf('opera')>-1,isIe=navigator.userAgent.toLowerCase().indexOf('msie')>-1;if((isWebkit||isOpera||isIe)&&document.getElementById&&window.addEventListener){window.addEventListener('hashchange',function(){var id=location.hash.substring(1),element;if(!(/^[A-z0-9_-]+$/.test(id))){return;} +element=document.getElementById(id);if(element){if(!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))){element.tabIndex=-1;} +element.focus();}},false);} diff --git a/layouts/authorprofile.php b/layouts/authorprofile.php new file mode 100644 index 0000000..7762d65 --- /dev/null +++ b/layouts/authorprofile.php @@ -0,0 +1,21 @@ + +
    + +
    +

    +
    + + \ No newline at end of file diff --git a/layouts/duoshuo.php b/layouts/duoshuo.php new file mode 100644 index 0000000..1f07b41 --- /dev/null +++ b/layouts/duoshuo.php @@ -0,0 +1,20 @@ + + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    + diff --git a/layouts/feature.php b/layouts/feature.php new file mode 100644 index 0000000..f82fa0f --- /dev/null +++ b/layouts/feature.php @@ -0,0 +1,21 @@ + +
    +

    +
    +
  • +
    +
  • +
  • +
    +
  • +
  • +
    +
  • +
    +
    diff --git a/layouts/feature_v2.php b/layouts/feature_v2.php new file mode 100644 index 0000000..fb6450a --- /dev/null +++ b/layouts/feature_v2.php @@ -0,0 +1,44 @@ + +
    +

    + + + +
    diff --git a/layouts/imgbox.php b/layouts/imgbox.php new file mode 100644 index 0000000..d270858 --- /dev/null +++ b/layouts/imgbox.php @@ -0,0 +1,143 @@ + +
    + +
    + +
    + +
    + +
    +

    + +
    +
  • + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • +
    + WeChat +
    +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + +
  • +
    + +
    + +
    +
  • + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • +
    + WeChat +
    +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + + +
  • + +
  • +
    + +
    + +
    + +
    + Previous Post

    %title


    ') ?> +
    + Next Post

    %title


    ') ?> +
    +
    + \ No newline at end of file diff --git a/layouts/sharelike.php b/layouts/sharelike.php new file mode 100644 index 0000000..1129351 --- /dev/null +++ b/layouts/sharelike.php @@ -0,0 +1,31 @@ + + + +
    + + + + +
    + + +
    +
      +
    • +
    • +
    • +
    • +
    + +
    + \ No newline at end of file diff --git a/layouts/sidebox.php b/layouts/sidebox.php new file mode 100644 index 0000000..4978fa6 --- /dev/null +++ b/layouts/sidebox.php @@ -0,0 +1,8 @@ + +
    diff --git a/options.php b/options.php new file mode 100644 index 0000000..78fc6fe --- /dev/null +++ b/options.php @@ -0,0 +1,849 @@ + __('1', 'options_framework_theme'), + 'two' => __('2', 'options_framework_theme'), + 'three' => __('3', 'options_framework_theme'), + 'four' => __('4', 'options_framework_theme'), + 'five' => __('5', 'options_framework_theme'), + 'six' => __('6', 'options_framework_theme'), + 'seven' => __('7', 'options_framework_theme') + ); + + + // 复选框数组 + $multicheck_array = array( + 'one' => __('椎名真白', 'options_framework_theme'), + 'two' => __('时崎狂三', 'options_framework_theme'), + 'three' => __('', 'options_framework_theme'), + 'four' => __('绉绸', 'options_framework_theme'), + 'five' => __('感化饼干', 'options_framework_theme') + ); + + // 复选框默认值 + $multicheck_defaults = array( + 'one' => '1', + 'five' => '1' + ); + + // 背景默认值 + $background_defaults = array( + 'color' => '', + 'image' => '', + 'repeat' => 'repeat', + 'position' => 'top center', + 'attachment'=>'scroll' ); + + // 版式默认值 + $typography_defaults = array( + 'size' => '15px', + 'face' => 'georgia', + 'style' => 'bold', + 'color' => '#bada55' ); + + // 版式设置选项 + $typography_options = array( + 'sizes' => array( '6','12','14','16','20' ), + 'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ), + 'styles' => array( 'normal' => '普通','bold' => '粗体' ), + 'color' => false + ); + + // 将所有分类(categories)加入数组 + $options_categories = array(); + $options_categories_obj = get_categories(); + foreach ($options_categories_obj as $category) { + $options_categories[$category->cat_ID] = $category->cat_name; + } + + // 将所有标签(tags)加入数组 + $options_tags = array(); + $options_tags_obj = get_tags(); + foreach ( $options_tags_obj as $tag ) { + $options_tags[$tag->term_id] = $tag->name; + } + + + // 将所有页面(pages)加入数组 + $options_pages = array(); + $options_pages_obj = get_pages('sort_column=post_parent,menu_order'); + $options_pages[''] = 'Select a page:'; + foreach ($options_pages_obj as $page) { + $options_pages[$page->ID] = $page->post_title; + } + + // 如果使用图片单选按钮, define a directory path + $imagepath = get_template_directory_uri() . '/images/'; + + $options = array(); + + //基本设置 + $options[] = array( + 'name' => __('基本设置', 'options_framework_theme'), + 'type' => 'heading'); + + $options[] = array( + 'name' => __('站点名称', 'options_framework_theme'), + 'desc' => __('樱花庄的白猫', 'options_framework_theme'), + 'id' => 'site_name', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('作者', 'options_framework_theme'), + 'desc' => __('Mashiro', 'options_framework_theme'), + 'id' => 'author_name', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __("主题风格", 'akina'), + 'id' => 'theme_skin', + 'std' => "#FE9600", + 'desc' => __('自定义主题颜色(此功能没有优化,建议使用#FE9600)', ''), + 'type' => "color" + ); + + $options[] = array( + 'name' => __('个人头像', 'options_framework_theme'), + 'desc' => __('最佳高度尺寸130*130px。', 'options_framework_theme'), + 'id' => 'focus_logo', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('logo', 'options_framework_theme'), + 'desc' => __('最佳高度尺寸40px。', 'options_framework_theme'), + 'id' => 'akina_logo', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('Favicon', 'options_framework_theme'), + 'desc' => __('就是浏览器标签栏上那个小 logo,填写url', 'options_framework_theme'), + 'id' => 'favicon_link', + 'std' => '/wp-content/themes/Sakura/images/favicon.ico', + 'type' => 'text'); + + $options[] = array( + 'name' => __('自定义关键词和描述', 'options_framework_theme'), + 'desc' => __('开启之后可自定义填写关键词和描述', 'options_framework_theme'), + 'id' => 'akina_meta', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('网站关键词', 'options_framework_theme'), + 'desc' => __('各关键字间用半角逗号","分割,数量在5个以内最佳。', 'options_framework_theme'), + 'id' => 'akina_meta_keywords', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('网站描述', 'options_framework_theme'), + 'desc' => __('用简洁的文字描述本站点,字数建议在120个字以内。', 'options_framework_theme'), + 'id' => 'akina_meta_description', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('展开导航菜单', 'options_framework_theme'), + 'desc' => __('勾选开启,默认收缩', 'options_framework_theme'), + 'id' => 'shownav', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('头部装饰图', 'options_framework_theme'), + 'desc' => __('默认开启,勾选关闭,显示在文章页面,独立页面以及分类页', 'options_framework_theme'), + 'id' => 'patternimg', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('搜索按钮', 'akina'), + 'id' => 'top_search', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('首页文章风格', 'akina'), + 'id' => 'post_list_style', + 'std' => "standard", + 'type' => "radio", + 'options' => array( + 'standard' => __('标准', ''), + 'imageflow' => __('图文', '') + )); + + $options[] = array( + 'name' => __('首页文章特色图(仅对标准风格生效)', 'akina'), + 'id' => 'list_type', + 'std' => "round", + 'type' => "radio", + 'options' => array( + 'round' => __('圆形', ''), + 'square' => __('方形', '') + )); + + $options[] = array( + 'name' => __('评论收缩', 'akina'), + 'id' => 'toggle-menu', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('文章末尾显示作者信息?', 'options_framework_theme'), + 'desc' => __('勾选启用', 'options_framework_theme'), + 'id' => 'show_authorprofile', + 'std' => '1', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('分页模式', 'akina'), + 'id' => 'pagenav_style', + 'std' => "ajax", + 'type' => "radio", + 'options' => array( + 'ajax' => __('ajax加载', ''), + 'np' => __('上一页和下一页', '') + )); + + $options[] = array( + 'name' => __('博主描述', 'options_framework_theme'), + 'desc' => __('一段自我描述的话', 'options_framework_theme'), + 'id' => 'admin_des', + 'std' => '一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。', + 'type' => 'textarea'); + + $options[] = array( + 'name' => __('页脚信息', 'options_framework_theme'), + 'desc' => __('页脚说明文字,支持HTML代码', 'options_framework_theme'), + 'id' => 'footer_info', + 'std' => '© 2018', + 'type' => 'textarea'); + + $options[] = array( + 'name' => __('Google 统计代码', 'options_framework_theme'), + 'desc' => __('UA-xxxxx-x', 'options_framework_theme'), + 'id' => 'google_analytics_id', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('站长统计(不建议使用)', 'options_framework_theme'), + 'desc' => __('填写统计代码,将被隐藏,如需要在下方填写链接地址', 'options_framework_theme'), + 'id' => 'site_statistics', + 'std' => '', + 'type' => 'textarea'); + + $options[] = array( + 'name' => __('网站地图地址', 'options_framework_theme'), + 'desc' => __('Sitemap生成的地图链接', 'options_framework_theme'), + 'id' => 'site_map_link', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('自定义CSS样式', 'options_framework_theme'), + 'desc' => __('直接填写CSS代码,不需要写style标签', 'options_framework_theme'), + 'id' => 'site_custom_style', + 'std' => '', + 'type' => 'textarea'); + + + //第一屏 + $options[] = array( + 'name' => __('第一屏', 'options_framework_theme'), + 'type' => 'heading'); + + $options[] = array( + 'name' => __('总开关', 'options_framework_theme'), + 'desc' => __('默认开启,勾选关闭', 'options_framework_theme'), + 'id' => 'head_focus', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('社交信息', 'options_framework_theme'), + 'desc' => __('默认开启,勾选关闭,显示头像、签名、SNS', 'options_framework_theme'), + 'id' => 'focus_infos', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('社交信息样式', 'akina'), + 'id' => 'social_style', + 'std' => "v2", + 'type' => "radio", + 'options' => array( + 'v2' => __('与签名合并', ''), + 'v1' => __('独立成行', '') + )); + + $options[] = array( + 'name' => __('全屏显示', 'options_framework_theme'), + 'desc' => __('默认开启,勾选关闭', 'options_framework_theme'), + 'id' => 'focus_height', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('开启视频', 'options_framework_theme'), + 'desc' => __('勾选开启', 'options_framework_theme'), + 'id' => 'focus_amv', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('Live', 'options_framework_theme'), + 'desc' => __('勾选开启,视频自动续播,需要开启Pjax功能', 'options_framework_theme'), + 'id' => 'focus_mvlive', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('视频地址', 'options_framework_theme'), + 'desc' => __('视频的来源地址,该地址拼接下面的视频名,地址尾部不需要加斜杠', 'options_framework_theme'), + 'id' => 'amv_url', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('视频名称', 'options_framework_theme'), + 'desc' => __('abc.mp4 ,只需要填写视频文件名 abc 即可,多个用英文逗号隔开如 abc,efg ,无需在意顺序,因为加载是随机的抽取的 ', 'options_framework_theme'), + 'id' => 'amv_title', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('背景图滤镜', 'akina'), + 'id' => 'focus_img_filter', + 'std' => "filter-nothing", + 'type' => "radio", + 'options' => array( + 'filter-nothing' => __('无', ''), + 'filter-undertint' => __('浅色', ''), + 'filter-dim' => __('暗淡', ''), + 'filter-grid' => __('网格', ''), + 'filter-dot' => __('点点', '') + )); + + $options[] = array( + 'name' => __('是否开启聚焦', 'options_framework_theme'), + 'desc' => __('默认开启', 'options_framework_theme'), + 'id' => 'top_feature', + 'std' => '1', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('聚焦样式', 'akina'), + 'id' => 'top_feature_style', + 'std' => "left_and_right", + 'type' => "radio", + 'options' => array( + 'left_and_right' => __('左右交替', ''), + 'bottom_to_top' => __('从下往上', '') + )); + + $options[] = array( + 'name' => __('聚焦标题', 'options_framework_theme'), + 'desc' => __('默认为聚焦,你也可以修改为其他,当然不能当广告用!不允许!!', 'options_framework_theme'), + 'id' => 'feature_title', + 'std' => '聚焦', + 'class' => 'mini', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图一', 'options_framework_theme'), + 'desc' => __('尺寸257px*160px', 'options_framework_theme'), + 'id' => 'feature1_img', + 'std' => $imagepath.'/temp.png', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('聚焦图一标题', 'options_framework_theme'), + 'desc' => __('聚焦图一标题', 'options_framework_theme'), + 'id' => 'feature1_title', + 'std' => 'feature1', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图一描述', 'options_framework_theme'), + 'desc' => __('聚焦图一描述', 'options_framework_theme'), + 'id' => 'feature1_description', + 'std' => 'Description goes here 1', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图一链接', 'options_framework_theme'), + 'desc' => __('聚焦图一链接', 'options_framework_theme'), + 'id' => 'feature1_link', + 'std' => '#', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图二', 'options_framework_theme'), + 'desc' => __('尺寸257px*160px', 'options_framework_theme'), + 'id' => 'feature2_img', + 'std' => $imagepath.'/temp.png', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('聚焦图二标题', 'options_framework_theme'), + 'desc' => __('聚焦图二标题', 'options_framework_theme'), + 'id' => 'feature2_title', + 'std' => 'feature2', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图二描述', 'options_framework_theme'), + 'desc' => __('聚焦图二描述', 'options_framework_theme'), + 'id' => 'feature2_description', + 'std' => 'Description goes here 2', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图二链接', 'options_framework_theme'), + 'desc' => __('聚焦图二链接', 'options_framework_theme'), + 'id' => 'feature2_link', + 'std' => '#', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图三', 'options_framework_theme'), + 'desc' => __('尺寸257px*160px', 'options_framework_theme'), + 'id' => 'feature3_img', + 'std' => $imagepath.'/temp.png', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('聚焦图三标题', 'options_framework_theme'), + 'desc' => __('聚焦图三标题', 'options_framework_theme'), + 'id' => 'feature3_title', + 'std' => 'feature3', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图三描述', 'options_framework_theme'), + 'desc' => __('聚焦图三描述', 'options_framework_theme'), + 'id' => 'feature3_description', + 'std' => 'Description goes here 3', + 'type' => 'text'); + + $options[] = array( + 'name' => __('聚焦图三链接', 'options_framework_theme'), + 'desc' => __('聚焦图三链接', 'options_framework_theme'), + 'id' => 'feature3_link', + 'std' => '#', + 'type' => 'text'); + + + //文章页 + $options[] = array( + 'name' => __('文章页', 'options_framework_theme'), + 'type' => 'heading'); + + $options[] = array( + 'name' => __('文章点赞', 'akina'), + 'id' => 'post_like', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('文章分享', 'akina'), + 'id' => 'post_share', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('上一篇下一篇', 'akina'), + 'id' => 'post_nepre', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('博主信息', 'akina'), + 'id' => 'author_profile', + 'std' => "yes", + 'type' => "radio", + 'options' => array( + 'yes' => __('开启', ''), + 'no' => __('关闭', '') + )); + + $options[] = array( + 'name' => __('支付宝打赏', 'options_framework_theme'), + 'desc' => __('支付宝二维码', 'options_framework_theme'), + 'id' => 'alipay_code', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('微信打赏', 'options_framework_theme'), + 'desc' => __('微信二维码', 'options_framework_theme'), + 'id' => 'wechat_code', + 'type' => 'upload'); + + + //社交选项 + $options[] = array( + 'name' => __('社交网络', 'options_framework_theme'), + 'type' => 'heading'); + + $options[] = array( + 'name' => __('微信', 'options_framework_theme'), + 'desc' => __('微信二维码', 'options_framework_theme'), + 'id' => 'wechat', + 'type' => 'upload'); + + $options[] = array( + 'name' => __('新浪微博', 'options_framework_theme'), + 'desc' => __('新浪微博地址', 'options_framework_theme'), + 'id' => 'sina', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('腾讯QQ', 'options_framework_theme'), + 'desc' => __('QQ号码', 'options_framework_theme'), + 'id' => 'qq', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Telegram', 'options_framework_theme'), + 'desc' => __('Telegram链接', 'options_framework_theme'), + 'id' => 'telegram', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('QQ空间', 'options_framework_theme'), + 'desc' => __('QQ空间地址', 'options_framework_theme'), + 'id' => 'qzone', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('GitHub', 'options_framework_theme'), + 'desc' => __('GitHub地址', 'options_framework_theme'), + 'id' => 'github', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Lofter', 'options_framework_theme'), + 'desc' => __('lofter地址', 'options_framework_theme'), + 'id' => 'lofter', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('BiliBili', 'options_framework_theme'), + 'desc' => __('B站地址', 'options_framework_theme'), + 'id' => 'bili', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('优酷视频', 'options_framework_theme'), + 'desc' => __('优酷地址', 'options_framework_theme'), + 'id' => 'youku', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('网易云音乐', 'options_framework_theme'), + 'desc' => __('网易云音乐地址', 'options_framework_theme'), + 'id' => 'wangyiyun', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Twitter', 'options_framework_theme'), + 'desc' => __('推特地址', 'options_framework_theme'), + 'id' => 'twitter', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Facebook', 'options_framework_theme'), + 'desc' => __('脸书地址', 'options_framework_theme'), + 'id' => 'facebook', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Google+', 'options_framework_theme'), + 'desc' => __('G+地址', 'options_framework_theme'), + 'id' => 'googleplus', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('简书', 'options_framework_theme'), + 'desc' => __('简书地址', 'options_framework_theme'), + 'id' => 'jianshu', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('CSDN', 'options_framework_theme'), + 'desc' => __('CSND社区地址', 'options_framework_theme'), + 'id' => 'csdn', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('知乎', 'options_framework_theme'), + 'desc' => __('知乎地址', 'options_framework_theme'), + 'id' => 'zhihu', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('邮箱-用户名', 'options_framework_theme'), + 'desc' => __('name@domain.com 的 name 部分,前端仅具有js运行环境时才能获取完整地址,可放心填写', 'options_framework_theme'), + 'id' => 'email_name', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('邮箱-域名', 'options_framework_theme'), + 'desc' => __('name@domain.com 的 domain.com 部分', 'options_framework_theme'), + 'id' => 'email_domain', + 'std' => '', + 'type' => 'text'); + + //其他 + $options[] = array( + 'name' => __('其他', 'options_framework_theme'), + 'type' => 'heading' ); + + $options[] = array( + 'name' => __('Cookie 版本控制', 'options_framework_theme'), + 'desc' => __('用于更新前端 cookie,可使用任意字符串,比如日期:---2018/5/16', 'options_framework_theme'), + 'id' => 'cookie_version', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('开启PJAX局部刷新', 'options_framework_theme'), + 'desc' => __('原理与Ajax相同', 'options_framework_theme'), + 'id' => 'poi_pjax', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('开启NProgress加载进度条', 'options_framework_theme'), + 'desc' => __('默认不开启,勾选开启', 'options_framework_theme'), + 'id' => 'nprogress_on', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('开启公告', 'options_framework_theme'), + 'desc' => __('默认不显示,勾选开启', 'options_framework_theme'), + 'id' => 'head_notice', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('公告内容', 'options_framework_theme'), + 'desc' => __('公告内容,文字超出142个字节将会被滚动显示(移动端无效),一个汉字 = 3字节,一个字母 = 1字节,自己计算吧', 'options_framework_theme'), + 'id' => 'notice_title', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('首页不显示的分类文章', 'options_framework_theme'), + 'desc' => __('填写分类ID,多个用英文“ , ”分开', 'options_framework_theme'), + 'id' => 'classify_display', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('图片展示分类', 'options_framework_theme'), + 'desc' => __('填写分类ID,多个用英文“ , ”分开', 'options_framework_theme'), + 'id' => 'image_category', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('发件地址前缀', 'options_framework_theme'), + 'desc' => __('用于发送系统邮件,在用户的邮箱中显示的发件人地址,不要使用中文,默认系统邮件地址为 poi@你的域名.com', 'options_framework_theme'), + 'id' => 'mail_user_name', + 'std' => 'poi', + 'type' => 'text'); + + $options[] = array( + 'name' => __('允许私密评论', 'options_framework_theme'), + 'desc' => __('允许用户设置自己的评论对其他人不可见', 'options_framework_theme'), + 'id' => 'open_private_message', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('机器人验证', 'options_framework_theme'), + 'desc' => __('开启机器人验证', 'options_framework_theme'), + 'id' => 'norobot', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('评论UA信息', 'options_framework_theme'), + 'desc' => __('勾选开启,用户的浏览器,操作系统信息', 'options_framework_theme'), + 'id' => 'open_useragent', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('开启多说插件支持', 'options_framework_theme'), + 'desc' => __('如果使用多说插件,请勾选此项', 'options_framework_theme'), + 'id' => 'general_disqus_plugin_support', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('后台登陆界面背景图', 'options_framework_theme'), + 'desc' => __('该地址为空则使用默认图片', 'options_framework_theme'), + 'id' => 'login_bg', + 'type' => 'upload'); + + + //前台登录 + $options[] = array( + 'name' => __('前台登录', 'options_framework_theme'), + 'type' => 'heading' ); + + $options[] = array( + 'name' => __('指定登录地址', 'options_framework_theme'), + 'desc' => __('强制不使用后台地址登陆,填写新建的登陆页面地址,比如 http://www.xxx.com/login【注意】填写前先测试下你新建的页面是可以正常打开的,以免造成无法进入后台等情况', 'options_framework_theme'), + 'id' => 'exlogin_url', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('指定注册地址', 'options_framework_theme'), + 'desc' => __('该链接使用在登录页面作为注册入口,建议填写', 'options_framework_theme'), + 'id' => 'exregister_url', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('允许用户注册', 'options_framework_theme'), + 'desc' => __('勾选开启,允许用户在前台注册', 'options_framework_theme'), + 'id' => 'ex_register_open', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('登录后自动跳转', 'options_framework_theme'), + 'desc' => __('勾选开启,管理员跳转至后台,用户跳转至主页', 'options_framework_theme'), + 'id' => 'login_urlskip', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('注册验证', 'options_framework_theme'), + 'desc' => __('勾选开启滑动验证', 'options_framework_theme'), + 'id' => 'login_validate', + 'std' => '0', + 'type' => 'checkbox'); + + //CDN 优化 + $options[] = array( + 'name' => __('CDN', 'options_framework_theme'), + 'type' => 'heading' ); + + $options[] = array( + 'name' => __('图片库 CDN', 'options_framework_theme'), + 'desc' => __('注意:填写格式为 http://你的CDN域名/20xx/xx/xx.png。
    也就是说,原路径为 http://your.domain/wp-content/uploads/2018/05/xx.png 的图片将从 http://你的CDN域名/2018/05/xx.png 加载', 'options_framework_theme'), + 'id' => 'qiniu_cdn', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Adobe Typekit ID 1', 'options_framework_theme'), + 'desc' => __('加载 Adobe 字体,请把这页七个字体都加入到你的 kit。免费账号有每月 2,5000 PV 的使用限制,可注册多个ID,每次随机选择一个调用,如果访问量没那么高,那么填这里第一个就OK了', 'options_framework_theme'), + 'id' => 'adobe_id_1', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Adobe Typekit ID 2', 'options_framework_theme'), + 'desc' => __('可留空,如果仅填前两个ID,那么随机到此 ID 的概率是1/3,随机到 ID 1 的概率是2/3', 'options_framework_theme'), + 'id' => 'adobe_id_2', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('Adobe Typekit ID 3', 'options_framework_theme'), + 'desc' => __('可留空,如果三个都填写,那么三个 ID 随机调用,概率各为 1/3', 'options_framework_theme'), + 'id' => 'adobe_id_3', + 'std' => '', + 'type' => 'text'); + + $options[] = array( + 'name' => __('开启 jsDelivr 测试?', 'options_framework_theme'), + 'desc' => __('如不清楚什么意思切勿勾选!', 'options_framework_theme'), + 'id' => 'jsdelivr_cdn_test', + 'std' => '0', + 'type' => 'checkbox'); + + $options[] = array( + 'name' => __('jsDelivr 版本号', 'options_framework_theme'), + 'desc' => __('如不清楚是什么意思切勿修改默认值!(默认值为latest)', 'options_framework_theme'), + 'id' => 'jsdelivr_cdn_version', + 'std' => 'latest', + 'type' => 'text'); + + return $options; +} \ No newline at end of file diff --git a/page-archive.php b/page-archive.php new file mode 100644 index 0000000..0eaa58b --- /dev/null +++ b/page-archive.php @@ -0,0 +1,50 @@ + + + + +
    > + +
    + +

    + +
    + have_posts() ) : $the_query->the_post(); + $year_tmp = get_the_time('Y'); + $mon_tmp = get_the_time('n'); + $y=$year; $m=$mon; + if ($mon != $mon_tmp && $mon > 0) $output .= '
    '; + if ($year != $year_tmp) { // 输出年份 + $year = $year_tmp; + $all[$year] = array(); + } + if ($mon != $mon_tmp) { // 输出月份 + $mon = $mon_tmp; + array_push($all[$year], $mon); + $output .= "

    $year-$mon

    "; + } + $output .= '
    '; + endwhile; + wp_reset_postdata(); + $output .= '
    '; + echo $output; + ?> +
    + + + + + diff --git a/page-links.php b/page-links.php new file mode 100644 index 0000000..e50c6b0 --- /dev/null +++ b/page-links.php @@ -0,0 +1,23 @@ + + + + + +
    > + + +
    +
    + + + +
    +
    + + + +
    +
    + + + +
    +
    + + + + + + + + + + + +
    +
    + + + diff --git a/single.php b/single.php new file mode 100644 index 0000000..208a4c4 --- /dev/null +++ b/single.php @@ -0,0 +1,27 @@ + +
    +
    + +
    +
    +ol,li>ul{margin-bottom:0;margin-left:1.5em}dt{font-weight:700}dd{margin:0 1.5em 1.5em}img{height:auto;max-width:100%}table{margin:0 0 1.5em;width:100%}button,input[type=button],input[type=reset],input[type=submit]{border:1px solid;border-color:#ccc #ccc #bbb;border-radius:3px;background:#e6e6e6;box-shadow:inset 0 1px 0 rgba(255,255,255,.5),inset 0 15px 17px rgba(255,255,255,.5),inset 0 -5px 12px rgba(0,0,0,.05);color:rgba(0,0,0,.8);font-size:12px;font-size:.75rem;line-height:1;padding:.6em 1em .4em}button:hover,input[type=button]:hover,input[type=reset]:hover,input[type=submit]:hover{border-color:#ccc #bbb #aaa;box-shadow:inset 0 1px 0 rgba(255,255,255,.8),inset 0 15px 17px rgba(255,255,255,.8),inset 0 -5px 12px rgba(0,0,0,.02)}button:active,button:focus,input[type=button]:active,input[type=button]:focus,input[type=reset]:active,input[type=reset]:focus,input[type=submit]:active,input[type=submit]:focus{border-color:#aaa #bbb #bbb;box-shadow:inset 0 -1px 0 rgba(255,255,255,.5),inset 0 2px 5px rgba(0,0,0,.15)}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=range],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week],textarea{color:#666;border:1px solid #ccc;border-radius:3px}select{border:1px solid #ccc}input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=range]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,textarea:focus{color:#111}input[type=color],input[type=date],input[type=datetime-local],input[type=datetime],input[type=email],input[type=month],input[type=number],input[type=password],input[type=range],input[type=search],input[type=tel],input[type=text],input[type=time],input[type=url],input[type=week]{padding:3px}textarea{padding-left:3px;width:100%;color:#A5A5A5}a{color:#e67474;outline:0;-webkit-transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out;-moz-transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out;transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out}a:active,a:focus,a:hover{color:orange}a:focus{outline:0}a:active,a:hover{outline:0;color:orange}.site-top{width:100%;display:block;margin:0 auto;padding:0 20px}@keyframes fade-in{0%{opacity:0}40%{opacity:0}100%{opacity:1}}@-webkit-keyframes fade-in{0%{opacity:0}40%{opacity:0}100%{opacity:1}}.wrapper{animation:fade-in;animation-duration:.5s;-webkit-animation:fade-in .5s}#bgvideo{position:absolute;top:0;left:0;margin:0;padding:0;min-width:99.999%;min-height:550px;z-index:0}#video-add,#video-btn{position:absolute;bottom:3px;right:5px;width:32px;height:32px;z-index:100;background-position:center;background-size:cover;cursor:pointer;opacity:.8;-moz-animation:poi-face 10s linear infinite alternate;-webkit-animation:poi-face 10s linear infinite alternate;-o-animation:poi-face 10s linear infinite alternate;animation:poi-face 10s linear infinite alternate}#video-add:hover,#video-btn:hover{opacity:1}.loadvideo,.video-play{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/play@32x32.png)}.video-pause{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/pause@32x32.png)}#video-add{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/add@32x32.png);bottom:45px;display:none}.video-stu{position:absolute;bottom:-100px;left:0;right:0;margin:auto;padding:6px 15px;text-align:center;color:#FFF;width:100%;background-color:rgba(0,0,0,.8);border-radius:0;font-size:18px;-webkit-transition:.4s ease all;-moz-transition:.4s ease all;-o-transition:.4s ease all;transition:.4s ease all}.pattern-center{position:relative;top:0;left:0;width:100%;overflow:hidden}.pattern-center::before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background-color:rgba(0,0,0,.3)}.pattern-center::after{content:'';width:150%;height:4.375rem;background:#fff;left:-25%;bottom:-2.875rem;border-radius:100%;position:absolute}.pattern-attachment-img{background-repeat:no-repeat;background-size:cover;background-position:center center;background-origin:border-box;width:100%;height:400px}.pattern-center header.pattern-header{position:absolute;top:45%;left:0;right:0;text-align:center;color:#FFF;z-index:1}.pattern-center h1.cat-title,.pattern-center h1.entry-title{color:#FFF;font-size:40px;font-weight:500;width:80%;margin:auto;padding:0;border:0}.pattern-center .cat-des{font-size:16px;display:block}.single-center::after{display:none}.pattern-center header.single-header{max-width:800px;padding:0 10px;margin-left:auto;margin-right:auto;text-align:left;top:auto;bottom:20px}.single-center .single-header h1.entry-title{margin:0;font-size:32px;width:100%}.single-center .entry-census{color:#fff;font-size:14px;padding:18px 0 0;line-height:39px}.single-center .entry-census .bull{margin:0 5px}.single-center .entry-census span img{width:35px;height:35px;border-radius:100%;float:left;margin-right:12px}.single-center .entry-census a{color:#fff}@media (max-width:860px){.pattern-center header.single-header{padding:0 4%}.pattern-attachment-img{height:280px}.pattern-center h1.cat-title,.pattern-center h1.entry-title,.single-center .single-header h1.entry-title{font-size:26px}}.pattern-center-sakura{position:relative;top:0;left:0;width:800px;overflow:hidden;margin:0 auto}.pattern-center-blank{padding-top:75px;background-color:#fff}@media (max-width:860px){.pattern-center-sakura{position:relative;top:0;left:0;width:100%;overflow:hidden}.pattern-center-blank{padding-top:0}}.pattern-center-sakura::before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background-color:rgba(0,0,0,.3)}.pattern-attachment-img{background-repeat:no-repeat;background-size:cover;background-position:center center;background-origin:border-box;width:100%;height:400px}.pattern-center-sakura header.pattern-header{position:absolute;top:45%;left:0;right:0;text-align:center;color:#FFF;z-index:1}.pattern-center-sakura h1.cat-title,.pattern-center-sakura h1.entry-title{color:#FFF;font-size:40px;font-weight:500;width:80%;margin:auto;padding:0;border:0}.pattern-center-sakura .cat-des{font-size:16px;display:block}.single-center::after{display:none}.pattern-center-sakura header.single-header{max-width:800px;padding:0 10px;margin-left:auto;margin-right:auto;text-align:left;top:auto;bottom:20px}.single-center .single-header h1.entry-title{margin:0;font-size:32px;width:100%}.single-center .entry-census{color:#fff;font-size:14px;padding:18px 0 0;line-height:39px}.single-center .entry-census .bull{margin:0 5px}.single-center .entry-census span img{width:35px;height:35px;border-radius:100%;float:left;margin-right:12px}.single-center .entry-census a{color:#fff}@media (max-width:860px){.pattern-center-sakura header.single-header{padding:0 4%}.pattern-attachment-img{height:280px}.pattern-center-sakura h1.cat-title,.pattern-center-sakura h1.entry-title,.single-center .single-header h1.entry-title{font-size:26px}}.site-header{width:100%;height:75px;background:0 0;-webkit-transition:all .4s ease;transition:all .4s ease;position:fixed;z-index:9999;top:0}.yya{position:fixed;left:0;background:rgba(255,255,255,.95);box-shadow:0 1px 40px -8px rgba(0,0,0,.5)}.gizle{top:-100px;top:0;z-index:9999}.site-header:hover{background-color:#fff}.sabit{top:0;z-index:9999}.site-branding{float:left;position:relative;height:75px;line-height:75px;margin-left:-6px}.site-title{margin:0}.site-title a{color:#464646;font-weight:400}.site-title a:hover{color:orange}.site-title img{height:40px;margin-top:17px;opacity:.75;-webkit-transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out;-moz-transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out;transition:color .2s ease-out,border .2s ease-out,opacity .2s ease-out}.site-title img:hover{opacity:1}.site-description{float:right}.header-focus{height:250px;background:#F9F9F9;margin:0 auto}.openNav{display:none}#mo-nav{display:none}.site-top .lower{position:relative;display:inline-block;float:right;margin:15px 0 0 0;font-size:16px}@media (max-width:860px){.site-top .lower nav ul li .animated-hover i{display:inline}}.site-top .lower nav{position:relative;float:right;display:none;animation:searchbox .2s}.site-top .lower nav.navbar{display:block}.m-nav{display:none}.site-top ul{margin:0;padding:0;list-style:none;display:inline-block}.site-top ul li{float:left;margin-left:28px;position:relative;-webkit-transition:all 1s ease}.site-top ul li a{padding:10px 0;display:inline-block;color:#666}.site-top ul li a:hover{color:orange}.site-top ul li a:after{content:"";display:block;position:absolute;bottom:-16px;height:6px;background-color:#FE9600;width:100%;max-width:0;transition:max-width .25s ease-in-out}.site-top ul li ul li a:after{content:"";display:none;position:absolute;bottom:-21px;height:6px;background-color:#FE9600;width:100%;max-width:0;transition:max-width .25s ease-in-out}.site-top ul li a:hover:after{max-width:100%}#show-nav{position:relative;float:right;margin-left:20px;display:block;width:30px;height:33px;margin-top:4.5px;cursor:pointer;z-index:999}#show-nav .line{position:absolute;top:7px;left:50%;width:28px;margin-left:-15px;height:2px;background:#666;-webkit-transition:all .2s ease}#show-nav.showNav .line1{top:16px}#show-nav.showNav .line3{top:25px}#show-nav.hideNav .line1{top:16px;-webkit-transform:rotateZ(45deg)}#show-nav.hideNav .line2{opacity:0}#show-nav.hideNav .line3{top:16px;-webkit-transform:rotateZ(-45deg)}.lower li ul{display:none;opacity:1;position:absolute;background:#fff;padding:10px;top:46px;right:-13px;width:80px;text-align:center;z-index:9999;border-radius:5px;box-shadow:0 1px 40px -8px rgba(0,0,0,.5);-webkit-animation:fadeInUp .3s .1s ease both;-moz-animation:fadeInUp .3s .1s ease both}.lower li ul::before{content:"";position:absolute;top:-20px;left:50%;margin-left:-10px;border-width:10px;border-style:solid;border-color:transparent transparent #fff transparent}@-webkit-keyframes fadeInUp{0%{opacity:0;-webkit-transform:translateY(10px)}100%{opacity:1;-webkit-transform:translateY(0)}}@-moz-keyframes fadeInUp{0%{opacity:0;-moz-transform:translateY(10px)}100%{opacity:1;-moz-transform:translateY(0)}}.lower li:hover ul{display:inline-block;-webkit-transition:all .4s;transition:all .4s}.lower li ul li{width:100%;margin:0}.site-top .menu-item-has-children li a{font-size:14px;padding:8px 18px;text-transform:none;color:#545454}.site-main{padding:40px 0 0}.site-content{max-width:800px;padding:0 10px;margin-left:auto;margin-right:auto;background-color:rgba(255,255,255,.8)}.post-list{margin:0 0 8% 0;position:relative}.feature{position:absolute;margin-top:10px}.feature i{position:absolute;top:10px;left:10px;font-size:25px;color:#fff;width:80px;height:80px;line-height:80px;text-align:center;background:#BBE2DB;border-radius:50%;opacity:0;z-index:1}.overlay i{-moz-transition:opacity .4s ease-out;-o-transition:opacity .4s ease-out;-webkit-transition:opacity .4s ease-out;transition:opacity .4s ease-out}.feature img{width:100px;height:100px;border-radius:50%;padding:2px;border:1px solid #DADADA;position:relative}.feature :hover .overlay i{opacity:1}.post-list h1.entry-title{font-size:20px;font-weight:400;line-height:50px;margin:0 0 0 17%;position:relative;z-index:1;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:70%}.entry-title a{color:#504E4E}.entry-title a:hover{color:orange}.p-time{position:absolute;right:0;top:16px;font-size:12px;color:#989898;letter-spacing:0}.p-time i{font-size:14px;margin-right:5px}i.iconfont.hotpost{font-size:14px;color:#FF3B00}.post-list p{min-height:60px;margin:0 0 0 17%;font-size:15px;color:rgba(0,0,0,.66);letter-spacing:0;line-height:30px}.entry-footer{margin:0 0 0 17%;list-style:none}.post-more{margin-top:10px;text-align:right}.post-more i{font-size:25px;color:#666}.post-more i:hover{color:#000}.info-meta{margin-top:10px;position:absolute;top:20px;opacity:0;padding-top:8px;border-top:1px solid #ddd;-webkit-transform:translate3d(-150px,0,0);transform:translate3d(-150px,0,0);visibility:hidden;transition:.7s all ease;-webkit-transition:.6s all ease;-moz-transition:.6s all linear;-o-transition:.6s all ease;-ms-transition:.6s all ease}.info-meta span{color:#000;font-size:13px;vertical-align:bottom}.info-meta i{margin-top:3px;margin-right:10px;float:left}.comnum{float:left}.info-meta a{color:#000}.post-list:hover .info-meta{-webkit-transform:translate3d(-230px,0,0);transform:translate3d(-230px,0,0);opacity:1;visibility:visible}.post-list hr{width:30%;height:1px;margin:0 auto;border:0;background:#EFEFEF;margin-top:20px}@media (max-width:860px){.site-main{padding:15px 0 0}}.post-list-thumb{float:left;width:100%;height:300px;position:relative;margin:20px 0 20px;border-radius:10px;background-color:rgba(255,255,255,0);box-shadow:0 1px 20px -8px rgba(0,0,0,.5);opacity:0}@media (max-width:860px){.post-list-thumb{margin:0;height:auto}}.post-list-thumb i{margin-right:5px;color:#989898;font-size:14px}.post-list-thumb a{color:#504E4E}.post-list-thumb .post-title h3{text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;word-wrap:break-word}.post-date,.post-meta,.post-meta a{color:#888;font-size:12px}.comments-number{margin:0 10px}.post-thumb{float:right;width:55%}.post-thumb a{height:300px;position:relative;display:block;background-repeat:no-repeat;background-size:cover;overflow:hidden;border-radius:0 10px 10px 0}.post-thumb a img{width:100%;height:100%;object-fit:cover;transition:all .6s}.post-thumb a img:hover{transform:scale(1.1)}.post-content-wrap{position:relative;display:inline-block;float:right;padding-right:30px;padding-left:0;width:40%;margin:20px 10px 0 10px}.float-content{position:relative;width:100%;right:0;margin:0;padding:0;z-index:50;color:rgba(0,0,0,.66)}.float-content .post-text{display:inline-block;text-align:justify;font-size:14px}.float-content i{font-size:25px;color:#666}.float-content p{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;height:67.5px;overflow:hidden}.post-list-thumb-left .post-content-wrap{float:left;padding-left:30px;padding-right:0;text-align:right;margin:20px 10px 10px 0}.post-list-thumb-left .post-thumb{float:left}.post-list-thumb-left .post-thumb a{border-radius:10px 0 0 10px}@media (max-width:768px){.float-content p{height:auto;display:block}.post-bottom{display:none}.post-list-thumb{padding:0;border:0;box-shadow:none}.float-content,.post-content-wrap,.post-thumb{width:100%;left:0}.post-content-wrap,.post-list-thumb-left .post-content-wrap{text-align:left;margin:0;padding:20px;float:none;box-shadow:none;border-top:0}.post-list-thumb::before{content:'';width:1px;height:100px;background-color:rgba(0,0,0,0);position:absolute;left:0;right:0;margin:auto;bottom:-101px;z-index:0}.float-content{box-shadow:none;padding:0;margin:0}.post-bottom{text-align:right}.post-thumb a{border-radius:10px}}@media (max-width:600px){.post-thumb a{height:210px}.float-content .post-text{font-size:13px;margin-bottom:1em}}.post-list-show{animation:post-list-show .5s;-webkit-animation:post-list-show .5s;opacity:1}@keyframes post-list-show{0%{opacity:0;-webkit-transform:translateY(80px);transform:translateY(80px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}.postava img{border-radius:50%;padding:2px;border:1px solid #E8E8E8;margin-top:25px}.postava{float:right}.post-status p{margin:0}.s-time{position:relative;top:16px;font-size:12px;color:#989898;letter-spacing:1px;text-align:right;margin-bottom:10px;margin-top:-15px}.s-content{min-height:60px;margin:0 14% 0 2%;padding:15px 30px;line-height:30px;border:1px dashed #E0E0E0;background:#FBFBFB}.s-time i{font-size:13px;margin-right:5px}.post-status{margin-bottom:80px}.navigator{text-align:center;margin:80px 0;display:block}.navigator a{display:inline-block;height:39px;line-height:39px;margin:20px 0}.navigator i{font-size:15px;color:#D8D8D8;padding:10px;border:2px solid #ddd;border-radius:50%;margin:0 10px}.navigator i:hover{color:#fff;background:orange;border:2px solid orange;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.site-footer{padding:2%;background:rgba(255,255,255,.8);max-width:800px;margin-left:auto;margin-right:auto}.site-info{text-align:center;font-size:13px;color:#B9B9B9}.site-info a{color:#B9B9B9}.site-info a:hover{color:orange}.footertext p{margin-bottom:8px}.footertext .foo-logo{width:30px;height:30px;opacity:.3;margin:0 auto;background-size:cover;background-position:center center;background-repeat:no-repeat;animation:poi-deg 12s infinite linear;-webkit-animation:poi-deg 12s infinite linear}.site-statistics{display:none}.entry-content .begin,.single-begin{float:left;font-size:3.6em;line-height:1em;margin-right:3px;margin-top:2px;font-weight:700}@media screen and (max-width:860px){.entry-content .begin,.single-begin{margin-top:6px}}.entry-content ul{list-style:disc;border:1px dashed #E4E4E4;padding:15px 10px 15px 50px;color:#616161;margin-left:0;border-radius:10px}.entry-content ol{list-style:decimal;border:1px dashed #E4E4E4;padding:15px 10px 15px 50px;color:#616161;margin-left:0;border-radius:10px}.entry-content ol li,.entry-content ul li{padding:8px 0}.entry-content{position:relative}.entry-content h3{padding-bottom:8px;border-bottom:1px dashed #ddd;color:#737373}.entry-content h3:before{content:"#";margin-right:5px;color:#FF6D6D}.entry-content h4:before{content:">";margin-right:5px;color:#FF6D6D}.entry-content h5:before{content:"•";margin-right:5px;color:#FF6D6D}.entry-content code{background:rgba(254,250,199,1);color:#E67474;word-break:break-word;font-family:'Source Code Pro',monospace,Helvetica,Tahoma,Arial,STXihei,"STHeiti Light","Microsoft YaHei",sans-serif;padding:2px;text-shadow:none;border-radius:5px}.entry-content a{color:#e67474;text-decoration:underline dotted rgba(0,0,0,.1)}.entry-content a:hover{color:orange;text-decoration:underline orange}h1.entry-title{font-size:24px;font-weight:300}.entry-content p{color:#797979}.entry-content p{line-height:30px}.entry-content hr{margin-top:40px;margin-bottom:40px;display:block;border:0;text-align:center;background:0 0}.entry-content hr:before{content:'...';display:inline-block;margin-left:.6em;color:rgba(0,0,0,.8);position:relative;top:-30px;font-size:28px;letter-spacing:.6em}.entry-content .post-password-form{text-align:center}.entry-header{margin:auto;text-align:left}.post .entry-header{text-align:center}.entry-census{font-size:12px;margin:0;color:#888}.entry-header hr{width:30%;height:1px;border:0;background:#EFEFEF;margin:20px auto}.Extendfull img{width:100%;border:5px solid #F3F3F3}h1.page-title{font-size:20px;font-weight:400;border:1px dashed #ddd;padding:10px 15px;color:#828282;margin-bottom:30px}h1.page-title.mb-{margin-top:100px}.cd-top{position:fixed;right:25px;top:-900px;z-index:99;width:70px;height:900px;background:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/scroll.png) no-repeat center;background-size:contain;-webkit-transition:all .5s ease-in-out;transition:all .5s ease-in-out;cursor:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/No_Disponible.cur),auto;opacity:1}.cd-top.cd-is-visible{opacity:1;top:-326px}.cd-top.cd-fade-out{opacity:1}.cd-top:hover{opacity:1}.cd-top span{display:none;color:#000;position:absolute;bottom:0;height:20px;width:50px;text-align:center}@media screen and (max-width:860px){.cd-top{display:none;height:60px;width:50px}.cd-top span{height:10px;width:50px}}#moblieGoTop{display:none;position:fixed;bottom:10px;right:10px;z-index:99;border:0;outline:0;background-color:#fff;color:#404040;cursor:pointer;padding:15px;border-radius:10px;border-radius:12px;box-shadow:0 0 2px 0 rgba(0,0,0,.12),0 2px 2px 0 rgba(0,0,0,.24);transition:box-shadow .2s ease}#moblieGoTop:hover{background-color:#fff;opacity:.8}.post-footer{padding:20px 0;border-bottom:1px dashed #ddd;border-top:1px dashed #ddd;margin-top:30px;height:82px}.post-lincenses{text-align:center;padding-bottom:5px;font-size:14px}.post-lincenses a:hover{color:#888}.post-lincenses a{color:#B3B3B3}.post-tags{float:left;font-size:13px;color:#B3B3B3;text-transform:uppercase}.post-tags a{color:#B3B3B3;margin-right:5px}.post-tags a:hover{color:orange}.post-tags i{margin-right:5px}.post-like{float:right}.post-like a{color:#9FE0DD;font-size:13px}.post-like i{font-size:13px}.post-like a.done{cursor:not-allowed}.post-share{float:right;list-style:none;margin-right:20px}.post-share img:hover{opacity:.8}.post-share ul{list-style:none;margin:0;padding:0;opacity:0;display:none;top:-3px;position:relative;-moz-transition:opacity .4s ease-out;-o-transition:opacity .4s ease-out;-webkit-transition:opacity .4s ease-out;transition:opacity .4s ease-out}.post-share li{float:left;margin-right:20px}.post-share li img{width:32px;height:32px;padding:7px}.post-share ul li i{font-size:20px}.post-share span{float:left;margin-right:10px}.post-share ul li a:hover{color:orange}.post-share .show-share{margin-left:10px;cursor:pointer;opacity:.6;float:right;-moz-transition:opacity .1s ease-out;-o-transition:opacity .1s ease-out;-webkit-transition:opacity .1s ease-out;transition:opacity .1s ease-out}.post-share:hover .sharehidden,.post-share:hover .show-share{opacity:1;display:inline-block}.post-squares{overflow:hidden;width:100%;margin:55px 0;background:#000}.post-squares .background{position:absolute;z-index:50;top:0;left:0;width:100%;height:100%;opacity:.4;background-size:cover;-webkit-transition:opacity .15s ease-out;-moz-transition:opacity .15s ease-out;transition:opacity .15s ease-out}.post-squares .info{position:relative;z-index:98}.post-squares a,.post-squares article{position:relative;display:block;float:left;overflow:hidden;height:100%;padding:55px 25px;text-align:center}.post-squares a:hover>.background,.post-squares article:hover>.background{opacity:.6}.post-squares .category{font-size:10px;padding:7px 15px;text-transform:uppercase;color:#fff;border-radius:90px;background:#7fbb00}.post-squares h3{font-size:17px;font-weight:400;line-height:30px;margin:20px 0;color:#fff;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:block}.post-squares h3 a{display:block;color:#fff}.post-squares hr{width:15%;height:0;border:0;background:rgba(255,255,255,.6)}.post-squares .label{font-size:13px;display:block;text-transform:uppercase;color:rgba(255,255,255,.7)}.post-squares .full{width:100%}.post-squares .half{width:50%;float:left}.post-squares .third{width:33.333%}@media (max-width:860px){.post-squares .third{width:100%}}@media (max-width:760px){.post-squares .half{float:none;width:100%}}@media (max-width:900px){.post-squares.post-squares-featured{display:none}}.post-squares.nextprev a,.post-squares.nextprev article{height:150px;padding:55px 40px;text-align:left}.post-squares.nextprev a{width:100%}.post-squares.nextprev .label{position:absolute;z-index:100;top:0}.post-squares.nextprev .info{position:absolute;width:70%}.post-squares.nextprev .next h3,.post-squares.nextprev .previous h3{font-size:14px}.post-squares.nextprev .previous{text-align:left}.post-squares.nextprev .previous .info{bottom:40px;left:40px}.post-squares.nextprev .previous .label{top:40px;left:40px}.post-squares.nextprev .previous hr{float:left;margin:0}.post-squares.nextprev .next .info{text-align:right}.post-squares.nextprev .next .info{right:40px;bottom:40px}.post-squares.nextprev .next .label{top:40px;right:40px}.post-squares.nextprev .next hr{float:right;margin:0}@media (max-width:760px){.post-squares.nextprev article{height:150px;width:100%}}.post-squares.post-squares-featured{height:250px}.author-profile{padding:30px 12.78%;text-align:center}.author-profile .info{overflow:hidden;text-align:center}.author-profile .profile{display:inline-block;width:70px;height:70px}.author-profile .profile img{max-width:100%;border-radius:100%;padding:3px;border:1px solid #ddd}.author-profile hr{width:50%;height:0;margin:0}.author-profile .meta{display:block;text-align:center}.author-profile .meta h3{margin:10px 0 0;text-transform:none}.author-profile .meta h3 a{font-size:18px;font-weight:400;line-height:normal;letter-spacing:1px;color:#ABABAB}.author-profile .meta .title{display:none}.author-profile p{font-size:13px;line-height:30px;margin:15px 0 0;color:#7d8588;letter-spacing:0;display:inline-block;padding:10px 20px;border-top:1px solid #EFEFEF;border-bottom:1px solid #EFEFEF}.author-profile i{color:#65C186;float:none;margin-right:10px;font-size:16px}.mashiro-profile{color:#7a7b7c;text-align:left;width:330px;height:100px;position:relative;top:70px;left:50%;transform:translate(-50%,-50%);border-radius:5px;background-color:#fafafa;box-shadow:0 0 2rem #babbbc;animation:show-profile .5s forwards ease-in-out}@keyframes show-profile{0%{width:0}}.mashiro-profile .content,.mashiro-profile .photo{box-sizing:border-box}.mashiro-profile .photo{width:100px;height:100px;border-radius:50%;overflow:hidden;border:5px solid #fafafa;background-color:#fafafa;margin-left:-50px;box-shadow:0 0 .5rem #babbbc;animation:rotate-photo .5s forwards ease-in-out}@keyframes rotate-photo{100%{transform:rotate(-360deg)}}.mashiro-profile .photo img{width:100%}.mashiro-profile .content{padding:10px;overflow:hidden;position:absolute;width:100%;height:100%;top:0;left:0}.mashiro-profile .content::before{content:"";position:absolute;width:230px;height:150px;background-color:#fef1c7;left:0;top:-20px;z-index:-1;transform:rotate(-8deg)}.mashiro-profile .content .text{margin-top:20px;margin-left:50px}.mashiro-profile .content .text h3,.mashiro-profile .content .text h6{font-weight:400;margin:3px 0;letter-spacing:.5px;white-space:nowrap}.mashiro-profile .content .btn{background-color:#abc;width:50px;height:50px;position:absolute;right:25px;top:25px;border-radius:50%;z-index:1;cursor:pointer;transition-duration:.3s;animation:pop-btn .3s both ease-in-out .5s}@keyframes pop-btn{0%{transform:scale(0)}80%{transform:scale(1.2)}100%{transform:scale(1)}}.mashiro-profile .content .btn:hover{box-shadow:0 0 0 5px rgba(170,187,204,.5)}.mashiro-profile .content .btn span{width:60%;height:2px;position:absolute;background-color:#fff;top:50%;left:20%;transform:translateY(-50%);animation:to-hamburger .3s forwards ease-in-out}.mashiro-profile .content .btn span::after,.mashiro-profile .content .btn span::before{content:"";width:100%;height:2px;position:absolute;background-color:#fff;transition-duration:.3s;transform:rotate(0);right:0}.mashiro-profile .content .btn span::before{margin-top:-7px}.mashiro-profile .content .btn span::after{margin-top:7px}.mashiro-profile .content .btn.active span{animation:to-arrow .3s forwards ease-in-out}.mashiro-profile .content .btn.active span::after,.mashiro-profile .content .btn.active span::before{width:60%;right:-1px}.mashiro-profile .content .btn.active span::before{transform:rotate(45deg)}.mashiro-profile .content .btn.active span::after{transform:rotate(-45deg)}@keyframes to-hamburger{from{transform:translateY(-50%) rotate(-180deg)}}@keyframes to-arrow{from{transform:translateY(-50%) rotate(0)}to{transform:translateY(-50%) rotate(180deg)}}.mashiro-profile .box{width:150px;height:150px;opacity:0;border-radius:50%;background-color:rgba(255,255,255,.7);position:absolute;top:50%;right:-40%;transform:translate(-50%,-50%);transition-duration:.3s}.mashiro-profile .box a{width:50px;height:50px;border-radius:50%;background-color:#ececec;font-size:26px;text-align:center;line-height:50px;position:absolute;left:18px;top:calc(75px - 50px/2);box-shadow:0 0 .5rem #babbbc;transition-duration:.3s;text-decoration:none}.mashiro-profile .box a:hover{transition-delay:initial!important;box-shadow:0 0 0 5px #babbbc}.mashiro-profile .box.open{opacity:1}.mashiro-profile .box.open a{left:60px}.mashiro-profile .box.open a:nth-of-type(1){transform:rotate(-90deg) translateX(120px) rotate(90deg);transition-delay:0s}.mashiro-profile .box.open a:nth-of-type(2){transform:rotate(-45deg) translateX(120px) rotate(45deg);transition-delay:.1s}.mashiro-profile .box.open a:nth-of-type(3){transform:rotate(0) translateX(120px) rotate(0);transition-delay:.2s}.mashiro-profile .box.open a:nth-of-type(4){transform:rotate(45deg) translateX(120px) rotate(-45deg);transition-delay:.3s}.mashiro-profile .box.open a:nth-of-type(5){transform:rotate(90deg) translateX(120px) rotate(-90deg);transition-delay:.4s}#loading-comments{display:none;max-width:860px;margin:0 auto;height:40px;text-align:center;line-height:45px;background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/disqus-preloader.svg);background-position:center;background-repeat:no-repeat;background-size:auto 100%}h3#comments-list-title{max-width:860px;width:100%;margin:0 auto;margin-bottom:40px;color:#7D7D7D;font-weight:400}#comments-list-title span{font-size:13px;font-weight:400;color:#909090}.butterBar{position:fixed;text-align:center;top:0;left:0;right:0;width:100%;z-index:10000}.butterBar--center{margin:auto}.butterBar-message{background:#FE9600;color:#fff;border-bottom-left-radius:4px;border-bottom-right-radius:4px;display:inline-block;font-size:14px;margin-bottom:0;padding:12px 25px;z-index:10000;margin-top:-4px}.alignleft{display:inline;float:left;margin-right:1.5em}.alignright{display:inline;float:right;margin-left:1.5em}.aligncenter{clear:both;display:block;margin-left:auto;margin-right:auto}.entry-content a img.aligncenter,.entry-content a img.alignleft,.entry-content a img.alignright{cursor:-webkit-zoom-in}#baguetteBox-overlay .full-image{cursor:-webkit-zoom-out}#baguetteBox-overlay .full-image figcaption,#baguetteBox-overlay .full-image img{cursor:auto}.clear:after,.clear:before,.comment-content:after,.comment-content:before,.entry-content:after,.entry-content:before,.site-content:after,.site-content:before,.site-footer:after,.site-footer:before,.site-header:after,.site-header:before{content:"";display:table;table-layout:fixed}.clear:after,.comment-content:after,.entry-content:after,.site-content:after,.site-footer:after,.site-header:after{clear:both}.sticky{display:block}.hentry{margin:0 0 1.5em}.byline,.updated:not(.published){display:none}.group-blog .byline,.single .byline{display:inline}.entry-summary,.page-content{margin:1.5em 0 0}.page-links{clear:both;margin:0 0 1.5em}span.edit-link{display:none}.archive .format-aside .entry-title,.blog .format-aside .entry-title{display:none}.clearer{display:block;clear:both}.works-list{float:left;width:32.5%;margin:0 3px}.works-entry{float:left;margin-bottom:8px}.works-main{width:100%;height:175px;position:relative;float:left;background:#F7F7F7;border:1px solid #F1F1F1;overflow:hidden}.works-feature img{width:257px;height:175px}h1.works-title{font-size:16px;font-weight:400;margin:0 0 10px 0;padding:0 20px;padding-top:40px}.works-title a{color:#6D6D6C}.works-main p{margin:0;padding:0 15px;line-height:20px}.works-p-time{float:left;font-size:12px;padding-left:20px;color:#B7B7B7}.works-p-time i{font-size:12px}.works-comnum a{color:#B7B7B7}.works-meta i{font-size:12px}.works-meta span{font-size:12px;float:right;margin-right:20px;color:#B7B7B7}.works-main .works-overlay{opacity:.95;top:-100%;-webkit-transition:.5s;-moz-transition:.5s;transition:.5s;color:#000}.works-overlay{position:absolute;left:0;top:0;background-color:#fff;height:100%;opacity:0;width:100%}.worksmore{position:absolute;width:100%;height:100%;top:0}.works-main:hover .works-overlay{top:0}#archives-temp{margin-top:50px;margin-bottom:100px}#archives-temp h2{font-weight:400;color:#676767;padding-bottom:15px;border-bottom:1px dashed #F1F1F1;text-align:center}#archives-temp h3{letter-spacing:2px;font-style:italic;font-size:20px;font-weight:400;color:orange;margin-left:30px;margin-top:50px}#archives-temp h3:hover{color:#ddd;cursor:pointer}span.time{float:right;color:#CACACA}.brick{margin-left:30px}.brick a{color:#7D7D7D;padding:20px 20px;background:#F5F5F5;margin-bottom:20px;display:block;letter-spacing:0}.ar-time i{padding:10px;border-radius:100px;background:orange;color:#fff}.ar-time{position:absolute;left:-18px;top:px;margin-top:3px}#archives-content{position:relative;border-left:1px dashed #F5F5F5}.arrow-left-ar{width:0;height:0;display:block;float:left;margin-top:10px;border-left:20px solid transparent;border-bottom:20px solid #F5F5F5;margin-left:11px}span.ar-circle{height:10px;width:10px;background:orange;display:inline-block;position:absolute;left:-5px;margin-top:22px;border-radius:100px}.brick em{font-style:normal;margin-left:5px}.time i{margin:3px}h1.cat-title{display:inline-block;font-size:25px;font-weight:400;padding-right:15px;border-right:1px dashed #ddd;color:#676767}.cat-des p{display:inline-block;padding-left:10px}header.page-header{position:relative;text-align:center;margin-bottom:50px;color:#9C9C9C}.links{margin-bottom:80px}.links ul{margin:0;list-style:none;padding:0;width:100%;display:inline-block}.links ul li{width:32%;float:left;border:1px solid #ECECEC;padding:10px 30px;margin:4px 4px;position:relative;overflow:hidden;-webkit-transition:all .3s;transition:all .3s;border-radius:10px}.links ul li img{float:right;box-shadow:inset 0 0 10px #000;padding:5px;opacity:1;transform:rotate(0);-webkit-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0);transition:all ease 1s;-webkit-transition:all ease 1s;-moz-transition:all ease 1s;-o-transition:all ease 1s;margin-top:5px;width:65px;height:65px;padding:2px;border-radius:100%}.links ul li:hover img{transform:rotate(360deg);-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}span.sitename{color:orange;padding-bottom:10px;display:block;-webkit-transition:all .3s;transition:all .3s;overflow:hidden;text-overflow:ellipsis;-o-text-overflow:ellipsis;white-space:nowrap}.linkdes{color:#949494;font-size:13px;padding:10px 0;border-top:1px dashed #ddd;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:25px;-webkit-transition:all .5s;transition:all .5s}.link-title{font-weight:400;color:#6D6D6D;padding-left:10px;border-left:3px solid orange;margin:50px 0 20px}.links ul li:before{content:"";background-color:orange;-webkit-transform:skew(45deg,0);transform:skew(45deg,0);width:0;height:100%;position:absolute;top:0;left:-60px;z-index:-1;-webkit-transition:all .5s;transition:all .5s}.links ul li:hover{color:#27323A;border:1px solid orange}.links ul li:hover:before{width:180%}.links ul li:hover .linkdes{border-top:1px dashed #fff}span.linkss-title{font-size:25px;text-align:center;display:block;margin:50px 0 30px;letter-spacing:5px}.notification-hidden{display:none}form#commentform{outline:0}nav#comments-navi{margin:0 auto;max-width:860px;width:100%;color:#9A9A9A}span.page-numbers.current{color:#74CCC4;padding:0 5px}a.page-numbers{color:#ABABAB;padding:0 5px}.comments{clear:both;overflow:hidden;width:100%;padding:60px 0 80px;list-style:none;background:rgba(255,255,255,.8);padding:0 10px;max-width:800px;margin-left:auto;margin-right:auto}.comments .commentwrap{width:100%;max-width:860px;margin:0 auto;padding:0}.comments .commentwrap hr{height:0;width:100%;background:#eee;border:0;margin:40px 0}@media (max-width:1080px){.comments .commentwrap{width:100%;padding:0 6.39%;max-width:1245px;margin-bottom:40px}}.comments .comments-hidden{display:none;cursor:pointer}.comments .comments-main{overflow:hidden;-webkit-transition:height 0s ease-out;-moz-transition:height 0s ease-out;transition:height 0s ease-out}.comments ul.commentwrap{margin:0 auto 30px}.comnav{width:100%;max-width:860px;margin:0 auto}.comnav a{padding:10px;color:#7B7B7B;margin-bottom:20px}@media (max-width:1080px){.comments{padding:6.39% 0 0;padding-bottom:80px;max-width:100%;padding:0 10px;max-width:800px;margin-left:auto;margin-right:auto}}@media (max-width:860px){.comments{padding:6.39% 0 0;max-width:100%;padding:0 10px;max-width:800px;margin-left:auto;margin-right:auto}}.comment{margin:0;padding:0;list-style:none}.comment .contents{width:100%;margin-bottom:5px;float:left;padding-bottom:25px}.comment .isauthor{display:none}.comment.bypostauthor>.contents .isauthor{display:inline}.comment .body{line-height:32px;color:#63686d;border-bottom:1px solid rgba(0,0,0,.05);position:relative}.comment .body p{font-size:14px;line-height:30px;margin-top:15px;padding-bottom:30px;padding-left:3px;color:#63686d}.comment .body p a{color:#000;padding:0 5px;text-decoration:underline}.comment .body .comment-at{color:#99ce00;text-decoration:none}@media (max-width:580px){.comment .body p{margin:0;font-size:12px;line-height:24px;padding-bottom:13px}}.comment .body>:last-child{margin-bottom:0}.comment .profile{float:left;margin-right:10px;margin-top:5px}.comment .profile img{width:100%;max-width:40px;height:40px;border-radius:100%;-webkit-transition:opacity .15s ease-out;-moz-transition:opacity .15s ease-out;transition:opacity .15s ease-out}.comment .profile img:hover{opacity:.8}.comment .main{float:right;width:100%;padding:0}.comment .commeta{font-size:16px;overflow:hidden;margin-bottom:5px;text-transform:uppercase;color:#9499a8;margin-left:50px}.comment .comment-reply-link{font-size:12px;display:block;margin-left:10px;float:right;text-transform:uppercase;color:#FFF;background-color:#e2684a;line-height:20px;padding:0 6px;border-radius:3px;opacity:0}.comment .contents:hover .comment-reply-link{opacity:.9}.comment .contents .comment-reply-link:hover{opacity:1}@media (max-width:880px){.comment .comment-reply-link{opacity:1}.comment .contents{padding-bottom:10px}.comment .commeta{margin-left:0}}.comment .info{margin-top:2px;font-size:12px;letter-spacing:0;text-transform:none;color:rgba(0,0,0,.35)}.comment .info .useragent-info img{vertical-align:sub;width:14px;height:14px;border:0}.comment .info .useragent-info-m{margin-top:2px;font-size:12px;letter-spacing:0;text-transform:none;color:rgba(0,0,0,.35);display:none}.comment .info .useragent-info-m img{vertical-align:sub;width:14px;height:14px;border:0}@media (max-width:480px){.comment .info .useragent-info{display:none}.comment .info .useragent-info-m{display:inline}}.comment h4{font-size:24px;font-weight:400;margin:0;letter-spacing:0;text-transform:none;line-height:20px}.comment h4 img{display:none;border-radius:3px;margin-right:5px;vertical-align:-4px}.comment h4 a{color:#e2684a;font-size:15px;font-weight:600}.comment h4 a:hover{color:orange}.comment hr{clear:both;width:100%;height:1px;margin:40px 0 60px;border:0;background:#e6e6e6}.comment .children{padding-left:40px;margin:0}.comment .children .children .children .children .children .children{margin:0;padding:0}.comment .children .profile{float:left;width:5%;margin-top:4px}.comment .children .profile img{height:40px;width:40px}.comment .children .main{width:100%}@media (max-width:880px){.comment hr{margin:6.39% 0}.comment .profile{display:none}.comment .children .main,.comment .main{width:100%}.comment h4 img{display:inline-block}.arrow-left{display:none}.comment .children{padding-left:2em;margin:0}.comment .children .children .children{margin:0;padding:0}}.comment-respond{width:100%;max-width:860px;margin:0 auto;padding:0}.comment-respond .logged-in-as{margin-bottom:0}.comment-respond #cancel-comment-reply-link{background:#f4f6f8;border-radius:3px;padding:12px 25px;font-size:12px;color:#454545}.comment-respond input,.comment-respond textarea{font-size:14px;width:31.3%;margin:0;padding:21px 21px 20px;color:#535a63;border:0;background:#FFF}.comment-respond input{border:1px solid #ddd;width:100%;background-color:rgba(255,255,255,0)}.comment-respond input:last-of-type{margin-right:0}@media (max-width:625px){.comment-respond input{width:100%;margin-bottom:15px}}.comment-respond textarea{display:block;float:none;width:100%;height:180px;margin-bottom:10px;color:#535a63;border:1px solid #ddd;background-color:rgba(255,255,255,0)}.comment-respond textarea{background-image:url(https://view.moezx.cc/images/2018/03/24/comment-bg.png);background-size:contain;background-repeat:no-repeat;background-position:right;background-color:rgba(255,255,255,0);resize:vertical}.comment-respond .form-submit{clear:both;display:block;overflow:hidden;margin-bottom:40px;padding:0}.comment-respond input[type=submit]{width:calc(98% - 46px);margin:0;padding:15px 25px;text-transform:none;color:#535a63;background:0 0;border-right:0;-webkit-transition:all .1s ease-out;-moz-transition:all .1s ease-out;transition:all .1s ease-out;box-shadow:none;border:1px solid #ccc;text-shadow:none}.comment-respond input[type=submit]:hover{border:1px solid #FE9600;background:0 0!important;color:#FE9600}.comment-respond input[type=submit]:hover{background:#5aa738}.comment-respond input:active,.comment-respond input:focus,.comment-respond textarea:active,.comment-respond textarea:focus{outline:0}.comment-respond input::-webkit-input-placeholder,.comment-respond textarea::-webkit-input-placeholder{color:#535a63}.comment-respond input:-moz-placeholder,.comment-respond textarea:-moz-placeholder{opacity:1;color:#535a63}.comment-respond input::-moz-placeholder,.comment-respond textarea::-moz-placeholder{opacity:1;color:#535a63}.comment-respond input:-ms-input-placeholder,.comment-respond textarea:-ms-input-placeholder{color:#535a63}@media (max-width:1080px){.comment-respond{width:100%;padding:0 6.39%;max-width:1245px}}.comment-respond .logged-in-as,.notification{padding:19px 32px 17px;border-radius:3px;background:#FFF;color:#6F6F6F}.comment-respond .logged-in-as{width:100%;max-width:100%;text-align:left;border:0;margin:0;padding:19px 5px 17px;background:0 0}.comment-respond .logged-in-as i,.notification i{margin-right:10px;font-size:16px}.comment-respond .logged-in-as a{color:#454545}.comment-respond .logged-in-as a:hover{color:#000}.notification{max-width:300px;margin:auto;text-align:center;border:1px solid #ddd}.notification span{font-size:13px;color:#B3B3B3}.siren-checkbox-label{position:relative;top:-8px;margin:0 20px 0 0;display:inline-block;cursor:pointer;color:#555;font-size:14px}.siren-checkbox-label input{padding:0;margin:0;float:none;width:initial}.siren-checkbox-radio{display:none}.siren-checkbox-radioInput{background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:100%;display:inline-block;height:18px;margin-right:8px;margin-top:-7px;vertical-align:sub;width:18px;line-height:1}.siren-checkbox-radio:checked+.siren-checkbox-radioInput:after{background-color:#FE9600;border-radius:100%;content:"";display:block;height:12px;margin:2px;width:12px}.siren-checkbox-radio:checked+.siren-is-private-checkbox.siren-checkbox-radioInput:after,.siren-is-private-checkbox.siren-checkbox-radioInput{border-radius:100%}@media (max-width:625px){.siren-checkbox-label{top:8px;margin-bottom:10px}}h1.fes-title,h1.main-title{color:#666;font-size:16px;font-weight:400;padding-bottom:5px;margin-bottom:30px;border-bottom:1px dashed #ECECEC}.feature-content{margin-top:10px;display:inline-block;position:relative}.top-feature{width:100%;height:auto;margin-top:55px}.top-feature img{height:160px;width:257px;border-radius:10px}.top-feature li{width:32.9%;float:left;margin:0 auto;position:relative;display:block}li.feature-2{margin-left:5px;margin-right:5px}.foverlay-bg{position:absolute;width:100%;height:160px;text-align:center;line-height:160px;color:#fff;font-size:32px;opacity:0;border-radius:10px;background:#02111D10;background:-webkit-linear-gradient(to right,#02111D80,#02111D20,#02111D80);background:linear-gradient(to right,#02111D80,#02111D10,#02111D80)}.top-feature li:hover .foverlay-bg{opacity:1}.feature-title .foverlay{color:#fff;font-size:32px;height:110px;text-align:center;border-radius:10px;z-index:-1;position:absolute;bottom:0;width:100%;-webkit-transform:translateY(calc(70px + 1em));transform:translateY(calc(70px + 1em));-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s}.foverlay{-moz-transition:opacity .4s ease-out;-o-transition:opacity .4s ease-out;-webkit-transition:opacity .4s ease-out;transition:opacity .4s ease-out}.top-feature li:hover .feature-title .foverlay{z-index:9;-webkit-transform:translateY(0);transform:translateY(0)}.notice{padding:20px;border:1px dashed #E6E6E6;color:#969696;position:relative;display:inline-block;width:100%;background:#fbfbfb50;border-radius:10px}.notice i{float:left;color:#999;font-size:18px;padding-right:10px}.notice-content{display:initial;vertical-align:middle}@media (max-width:860px){.notice{margin-top:40px;margin-bottom:20px}}.headertop{position:relative;overflow:hidden;height:0}.headertop::before{content:'';position:absolute;top:0;bottom:0;left:0;right:0;z-index:3;background-attachment:fixed}.headertop.filter-undertint::before{background-color:rgba(255,255,255,.3)}.headertop.filter-dim::before{background-color:rgba(0,0,0,.3)}.headertop.filter-grid::before{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/grid.png)}.headertop.filter-dot::before{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/dot.gif)}@media (max-width:860px){.headertop.filter-dot::before{background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/grid.png)}}.headertop-bar::after{content:'';width:150%;height:4.375rem;background:#fff;left:-25%;bottom:-2.875rem;border-radius:100%;position:absolute;z-index:4}#centerbg{width:100%;height:550px;margin:0;padding:0;background-position:top center;background-repeat:no-repeat;background-attachment:fixed;background-size:cover;z-index:-1}@media (max-width:860px){#centerbg{height:300px;background-attachment:scroll}#video-container,.focusinfo{display:none}}.blank{padding-top:80px;background-color:rgba(255,255,255,1)}.focusinfo{position:relative;max-width:800px;padding:0 10px;top:49.3%;left:50%;transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);text-align:center;z-index:99;-webkit-transition:.4s ease all;-moz-transition:.4s ease all;-o-transition:.4s ease all;transition:.4s ease all}.focusinfo img{width:130px;height:130px;padding:2px;border-radius:100%}.focusinfo .header-tou img{box-shadow:inset 0 0 10px #000;padding:5px;opacity:1;transform:rotate(0);-webkit-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0);transition:all ease 1s;-webkit-transition:all ease 1s;-moz-transition:all ease 1s;-o-transition:all ease 1s}.focusinfo .header-tou img:hover{transform:rotate(360deg);-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}.bio-text{position:relative;width:auto;font-size:40px;height:40px;top:50%}.bio-text p{display:inline-block;vertical-align:top;margin:0}.bio-text .word{position:absolute;opacity:0;white-space:nowrap;left:50%;transform:translate(-50%,0)}.bio-text .letter{display:inline-block;position:relative;-webkit-transform:translateZ(25px);transform:translateZ(25px);-webkit-transform-origin:50% 50% 25px;transform-origin:50% 50% 25px}.bio-text .letter.out{-webkit-transform:rotateX(90deg);transform:rotateX(90deg);-webkit-transition:-webkit-transform .32s cubic-bezier(.55,.055,.675,.19);transition:-webkit-transform .32s cubic-bezier(.55,.055,.675,.19);transition:transform .32s cubic-bezier(.55,.055,.675,.19);transition:transform .32s cubic-bezier(.55,.055,.675,.19),-webkit-transform .32s cubic-bezier(.55,.055,.675,.19)}.bio-text .letter.behind{-webkit-transform:rotateX(-90deg);transform:rotateX(-90deg)}.bio-text .letter.in{-webkit-transform:rotateX(0);transform:rotateX(0);-webkit-transition:-webkit-transform .5s cubic-bezier(.175,.885,.32,1.275);transition:-webkit-transform .5s cubic-bezier(.175,.885,.32,1.275);transition:transform .5s cubic-bezier(.175,.885,.32,1.275);transition:transform .5s cubic-bezier(.175,.885,.32,1.275),-webkit-transform .5s cubic-bezier(.175,.885,.32,1.275)}.wisteria{color:#8e44ad}.belize{color:#2980b9}.pomegranate{color:#c0392b}.green{color:#16a085}.midnight{color:#2c3e50}.header-info{width:63%;margin:auto;font-size:16px;color:#EAEADF;background:rgba(0,0,0,.5);padding:15px;margin-top:22px;letter-spacing:0;line-height:30px;border-radius:10px;box-sizing:initial;white-space:nowrap}.header-info:before{content:"";position:absolute;top:127px;left:50%;margin-left:-15px;border-width:15px;border-style:solid;border-color:transparent transparent rgba(0,0,0,.5) transparent}.header-info p{margin:0;font-family:Ubuntu,sans-serif;font-weight:700}.top-social{height:32px;margin-top:30px;margin-left:10px;list-style:none;display:inline-block}.top-social img{height:35px;width:35px;padding:6px;background:rgba(0,0,0,.4)}.top-social li{float:left;margin-right:10px}.top-social_v2{height:32px;margin-bottom:-15px;margin-left:10px;list-style:none;display:inline-block}.top-social_v2 img{height:35px;width:35px;padding:6px;background:0 0}.top-social_v2 li{float:left;margin-right:13px}.wechat{width:35px;height:35px;position:relative}.wechatInner img{border-radius:0;width:121px;height:auto;padding:0;background:0 0}.wechatInner{width:121px;height:121px;padding:10px;background:rgba(0,0,0,.4);top:40px;left:-40px;-webkit-transform:translate3d(0,50px,0);transform:translate3d(0,50px,0);opacity:0}.wechatInner:before{content:"";position:absolute;top:-30px;left:50%;margin-left:-15px;border-width:15px;border-style:solid;border-color:transparent transparent rgba(0,0,0,.4) transparent}.wechatInner{position:absolute;border-radius:8px;transition:.7s all ease;-webkit-transition:.7s all ease;-moz-transition:.7s all linear;-o-transition:.7s all ease;-ms-transition:.7s all ease}.wechat:hover .wechatInner{-webkit-transform:translate3d(0,16px,0);transform:translate3d(0,16px,0);opacity:1;visibility:visible}.searchbox{float:right;height:75px;line-height:75px;margin-left:20px}.site-header.iconsearch{font-size:18px;font-size:1.125rem;position:relative;z-index:9998}.site-header.iconsearch:hover{cursor:pointer;color:#999}i.iconfont.js-toggle-search.iconsearch{color:#666;cursor:pointer;font-size:26px;-webkit-transition:all .3s ease-in-out;transition:all .3s ease-in-out}.search-form--modal{-webkit-transition:visibility .25s ease,opacity .25s ease;-moz-transition:visibility .25s ease,opacity .25s ease;-ms-transition:visibility .25s ease,opacity .25s ease;-o-transition:visibility .25s ease,opacity .25s ease;transition:visibility .25s ease,opacity .25s ease;overflow:hidden;z-index:9999;position:fixed;top:0;right:0;left:0;bottom:0;background:#fff;visibility:hidden;opacity:0}.search-form--modal .search-form__inner{max-width:640px;padding:0 20px;margin:auto;text-align:left;position:absolute;width:100%;left:0;right:0;height:285px;top:0;bottom:0}.search-form--modal .search-form__inner p{padding-left:24px}.search-form.is-visible{visibility:visible;opacity:.99;animation:elastic .5s;background-image:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.2.1/img/other/iloli.gif);background-repeat:no-repeat;background-position:bottom right}.search-form div{position:relative}.search-form .search_close{position:absolute;width:35px;height:35px;background:0 0;top:20px;right:15px;cursor:pointer}.search_close:after,.search_close:before{background-color:#222;position:absolute;content:"";width:30px;height:2px;top:17px;left:2px}.search_close:before{transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}.search_close:after{transform:rotate(45deg);-webkit-transform:rotate(45deg)}.search-form i{font-size:32px;font-size:2rem;line-height:1;color:#ddd;position:absolute;bottom:15px;margin-top:-16px;left:16px}.search-form input{font-size:24px;font-size:1.5rem;background:#FFF;padding:12px 24px 12px 64px;width:100%;outline:0;border-radius:50px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.search-form input::-webkit-input-placeholder{color:#ddd}.search-form input:-moz-placeholder{color:#ddd}.search-form input::-moz-placeholder{color:#ddd}.search-form input:-ms-input-placeholder{color:#ddd}.s-search{position:relative;margin-bottom:50px}.s-search input{font-size:1rem;background:#none;padding:12px 24px 12px 64px;width:100%;outline:0;border-radius:50px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.s-search i{font-size:32px;font-size:1.5rem;line-height:1;color:#ddd;position:absolute;bottom:12px;margin-top:-16px;left:16px}.search-no-reasults{list-style-type:decimal}.sorry ul{padding:0 0 0 20px;margin:0}.sorry li a{color:#8C8C8C}.sorry{color:#8C8C8C;margin-bottom:80px}.sorry li{padding:10px 0}.sorry li a:hover{color:orange}.sorry-inner{padding:20px;border:1px solid #ddd}.error-img{text-align:center}.err-button.back{text-align:center}.err-button.back a{padding:10px 30px;margin:0 10px;border:1px solid orange;color:orange;-webkit-border-radius:50px;-moz-border-radius:50px;border-radius:50px}#gohome{background:orange;color:#fff}.err-button.back a:hover{-webkit-box-shadow:0 0 4px rgba(255,165,0,.85);-moz-box-shadow:0 0 4px rgba(255,165,0,.85);-o-box-shadow:0 0 4px rgba(255,165,0,.85);box-shadow:0 0 4px rgba(255,165,0,.85)}#baguetteBox-overlay{display:none;opacity:0;position:fixed;overflow:hidden;top:0;left:0;width:100%;height:100%;z-index:1000000;background-color:rgba(0,0,0,.8);transition:opacity .5s ease;animation:elastic .5s}#baguetteBox-overlay.visible{opacity:1}#baguetteBox-overlay .full-image{display:inline-block;position:relative;width:100%;height:100%;text-align:center}#baguetteBox-overlay .full-image figure{display:inline;margin:0;height:100%}#baguetteBox-overlay .full-image img{display:inline-block;width:auto;height:auto;max-height:80%;max-width:80%;vertical-align:middle;box-shadow:0 0 170px #ddd}#baguetteBox-overlay .full-image figcaption{display:block;position:absolute;bottom:0;width:100%;text-align:center;line-height:3;color:#eee;background-color:#000;background-color:rgba(0,0,0,.8)}#baguetteBox-overlay .full-image:before{content:"";display:inline-block;height:50%;width:1px;margin-right:-1px}#baguetteBox-slider{position:absolute;left:0;top:0;height:100%;width:100%;white-space:nowrap;transition:left .4s ease,-webkit-transform .4s ease;transition:left .4s ease,-moz-transform .4s ease;transition:left .4s ease,transform .4s ease}#baguetteBox-slider.bounce-from-right{-webkit-animation:bounceFromRight .4s ease-out;animation:bounceFromRight .4s ease-out}#baguetteBox-slider.bounce-from-left{-webkit-animation:bounceFromLeft .4s ease-out;animation:bounceFromLeft .4s ease-out}.baguetteBox-button#next-button,.baguetteBox-button#previous-button{top:50%;top:calc(50% - 30px);width:44px;height:60px}.baguetteBox-button{position:absolute;cursor:pointer;outline:0;padding:0;margin:0;border:0;background:rgba(255,255,255,0);box-shadow:none;border-radius:0;color:#ddd;font:1.6em sans-serif}.baguetteBox-button:hover{box-shadow:none}.baguetteBox-button#next-button{right:2%;box-shadow:none}.baguetteBox-button#previous-button{left:2%;box-shadow:none}.baguetteBox-button#close-button{top:23px;right:18px;right:calc(2% + 6px);width:30px;height:30px;display:none}.baguetteBox-button svg{position:absolute;left:0;top:0}.spinner{width:40px;height:40px;display:inline-block;position:absolute;top:50%;left:50%;margin-top:-20px;margin-left:-20px}.double-bounce1,.double-bounce2{width:100%;height:100%;-moz-border-radius:50%;border-radius:50%;background-color:#fff;opacity:.6;position:absolute;top:0;left:0;-webkit-animation:bounce 2s infinite ease-in-out;animation:bounce 2s infinite ease-in-out}.double-bounce2{-webkit-animation-delay:-1s;animation-delay:-1s}@-webkit-keyframes bounceFromRight{0%{margin-left:0}50%{margin-left:-30px}100%{margin-left:0}}@keyframes bounceFromRight{0%{margin-left:0}50%{margin-left:-30px}100%{margin-left:0}}@-webkit-keyframes bounceFromLeft{0%{margin-left:0}50%{margin-left:30px}100%{margin-left:0}}@keyframes bounceFromLeft{0%{margin-left:0}50%{margin-left:30px}100%{margin-left:0}}@-webkit-keyframes bounce{0%,100%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes bounce{0%,100%{-webkit-transform:scale(0);-moz-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1);-moz-transform:scale(1);transform:scale(1)}}.infinite-scroll .posts-navigation,.infinite-scroll.neverending .site-footer{display:none}.infinity-end.neverending .site-footer{display:block}.comment-content .wp-smiley,.entry-content .wp-smiley,.page-content .wp-smiley{border:none;margin-bottom:0;margin-top:0;padding:0}embed,iframe,object{max-width:100%}.wp-caption{margin-bottom:1.5em;max-width:100%}.wp-caption img[class*=wp-image-]{display:block;margin-left:auto;margin-right:auto}.wp-caption .wp-caption-text{margin:.8075em 0}.wp-caption-text{text-align:center}.gallery{margin-bottom:1.5em}.gallery-item{display:inline-block;text-align:center;vertical-align:top;width:100%;margin:0}.gallery-columns-2 .gallery-item{max-width:50%}.gallery-columns-3 .gallery-item{max-width:33.33%}.gallery-columns-4 .gallery-item{max-width:25%}.gallery-columns-5 .gallery-item{max-width:20%}.gallery-columns-6 .gallery-item{max-width:16.66%}.gallery-columns-7 .gallery-item{max-width:14.28%}.gallery-columns-8 .gallery-item{max-width:12.5%}.gallery-columns-9 .gallery-item{max-width:11.11%}.gallery-caption{display:none}.gallery img{width:100%;height:180px;border-radius:0;transition:all 2s ease;-webkit-transition:all 2s ease;-ms-transition:all 2s ease}.gallery .gallery-item{display:inline-block;vertical-align:top;float:left;width:280px;height:180px;position:relative}.gallery .gallery-item{-moz-transition:all .25s ease;-webkit-transition:all .25s ease;-o-transition:all .25s ease;-ms-transition:all .25s ease;transition:all .25s ease}.gallery:hover .gallery-item:not(:hover){opacity:.7;-moz-transform:scale(.9);-ms-transform:scale(.9);-webkit-transform:scale(.9);-o-transform:scale(.9);transform:scale(.9)}#nprogress{pointer-events:none;z-index:99999;position:absolute}#nprogress .bar{background:orange;position:fixed;z-index:1031;top:0;left:0;width:100%;height:3px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px orange,0 0 5px orange;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:9999;top:27px;right:24px;left:inherit;width:auto;height:auto;margin:0}#nprogress .spinner-icon{width:20px;height:20px;box-sizing:border-box;border:solid 3px transparent;border-top-color:orange;border-left-color:orange;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.download{color:#fff!important;-webkit-transition:all .3s;-moz-transition:all .3s;-o-transition:all .3s;transition:all .3s;position:relative;border:1px solid #72C5A6;overflow:hidden;display:inline-block;background:#72C5A6}.download:hover{color:#fff}.download::after,.download::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;-webkit-transition:all .3s;-moz-transition:all .3s;-o-transition:all .3s;transition:all .3s;opacity:1;-webkit-transform:translate(0,-105%);transform:translate(0,-105%);border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgba(255,255,255,1);background-color:rgba(255,255,255,.25)}.download::after{-webkit-transition-delay:.2s;transition-delay:.2s}.download:hover::after,.download:hover::before{opacity:0;-webkit-transform:translate(0,0);transform:translate(0,0)}.download span{padding:10px 30px;display:inline-block}i.iconfont.down{margin-right:6px;font-size:18px;position:relative;top:1px}#pagination{width:100%;padding:20px 0;text-align:center;margin:40px 0 80px;display:inline-block}#pagination a:hover{-webkit-box-shadow:0 0 4px rgba(255,165,0,.85);-moz-box-shadow:0 0 4px rgba(255,165,0,.85);-o-box-shadow:0 0 4px rgba(255,165,0,.85);box-shadow:0 0 4px rgba(255,165,0,.85)}#pagination a{padding:13px 35px;border:1px solid #D6D6D6;border-radius:50px;color:#ADADAD}#pagination span{color:#989898;font-size:15px}#pagination a:hover{border:1px solid orange;color:orange}#pagination .loading{background:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/wordpress-rotating-ball-o.svg);background-position:center;background-repeat:no-repeat;color:#555;border:none;background-size:auto 100%}#pagination .loading:hover{border:none;-webkit-box-shadow:none;-moz-box-shadow:none;-o-box-shadow:none;box-shadow:none}#pagination.pagination-archive{margin:80px 0}@media (max-width:630px){.works-list{width:100%!important;margin:0!important}}@media (max-width:630px){.links ul li{width:100%!important}.we-content li{width:100%;margin-top:0}.we-icon{top:50px!important}.wtitle{top:130px!important}.sub-text{top:160px!important}.admin-login,.wesite-des{display:none}.wesite-title{float:none;text-align:center;border-right:none;padding-right:0}}@media (max-width:860px){.comments{max-width:100%!important}.top-feature,.top-feature-row{display:none}.site-content{padding:0 4%}.feature img{width:52px;height:52px}.post-list h1.entry-title{margin:0 0 0 65px;font-size:16px;line-height:30px}.p-time{position:relative;margin:-15px 0 0 65px}.post-list p{margin:20px 0 0 65px;font-size:14px;height:30px;overflow:hidden}.s-content{padding:10px 15px;margin-right:65px}.s-content p{margin-left:0;margin-top:0;height:30px;overflow:hidden}.postava img{width:52px;height:52px}.overlay{display:none}.info-meta{display:none}.post-more{display:none}h1.entry-title{font-size:18px}.entry-content p{font-size:14px}.post-footer,.post-like,.post-share{display:none}.post-tags{text-align:center;float:none;font-size:12px}.author-profile{display:none}.site-footer{padding:30px}.lower{display:none!important}.m-nav{display:block}.site-header{display:none}.site-branding{float:right;height:50px;line-height:43px;margin-right:-6px}.site-title img{height:40px;line-height:40px;margin:0;vertical-align:middle}.site-title{font-size:20px;margin-right:10px}.links ul li{width:48.6%}.links ul li:before{display:none}.links ul li:hover .sitename{color:orange}.links ul li:hover .linkdes{color:#949494;border-top:1px dashed #ddd}.author-box{display:none}#archives-temp{padding:0 20px}}@media (max-width:1080px){.info-meta{display:none}.site-footer{padding:30px}.we-title:before{display:none}h3#comments-list-title,nav#comments-navi{width:100%;padding:0 6.39%;max-width:1245px}}@media (max-width:860px){#main-container{transition-duration:.5s;position:relative;overflow:hidden;z-index:2}#main-container.open:before{content:"";width:100%;height:100%;position:fixed;background-color:rgba(0,0,0,.4);z-index:99}#main-container.open{transform:translateX(250px) translateY(0);-webkit-transform:translateX(250px) translateY(0);position:fixed;right:0;left:0}.wrapper{transition-duration:.5s;width:100%;height:auto;position:relative}#mo-nav.open{width:250px}.wrapper section{max-width:600px}.wrapper section h1{font-weight:300;font-size:30px;margin-bottom:10px}.wrapper section h2{font-weight:300;font-size:20px;margin-bottom:40px}.wrapper section p{margin-bottom:40px}.openNav{transition-duration:.5s;width:100%;height:50px;position:absolute;top:0;z-index:99999;display:block;background:0 0}.iconflat{background:0 0;width:50px;height:50px;float:left}.openNav .icon{transition-duration:.2s;position:absolute;width:30px;height:3px;background-color:#333;top:24px;left:10px}.openNav .icon:after,.openNav .icon:before{transition-duration:.5s;background-color:#333;position:absolute;content:"";width:30px;height:3px;left:0}.openNav .icon:before{top:-8px}.openNav .icon:after{top:8px}.openNav.open .icon{background-color:transparent}.openNav.open .icon:after,.openNav.open .icon:before{top:0}.openNav.open .icon:before{transform:rotate(-45deg);-webkit-transform:rotate(-45deg);background:#FFF}.openNav.open .icon:after{transform:rotate(45deg);-webkit-transform:rotate(45deg);background:#FFF}#mo-nav{background-color:#FFF;width:0;max-width:250px!important;height:100%;z-index:999;position:absolute;top:0;left:0;display:block;overflow-x:hidden!important;overflow-y:auto}#mo-nav .m-avatar{position:relative;width:250px;max-width:250px;height:auto;margin:0 auto;padding:30px 0 20px;text-align:center}#mo-nav .m-avatar img{width:90px;height:90px;max-width:90px;border-radius:100%}#mo-nav .m-search form{position:relative;width:250px;max-width:250px;margin:0 0 20px;padding:8px 15px;background-color:#fafafa}#mo-nav .m-search input{width:100%;border:0;padding:5px;text-align:center;border-radius:3px;outline:0}#mo-nav ul{width:200px;height:auto;margin:10px 9px}#mo-nav ul:hover li{color:rgba(255,255,255,.5)}#mo-nav ul li{transition-duration:.25s;display:block;padding:6px 40px;color:#fff;letter-spacing:.02em;text-align:left}#mo-nav ul li a{color:#333;font-size:15px}#mo-nav li ul{width:250px;margin:10px 0;padding-left:10px}#mo-nav li ul li{padding:5px 9px}#mo-nav li ul li a{font-size:13px;color:#9CACC5}#mo-nav ul li a:hover{cursor:pointer;color:orange}.we-content li{height:250px}.we-content{padding:80px 1%}.we-icon{top:30px}.wtitle{top:110px}.sub-text{top:150px}.works-list{width:46.88%;margin:0 1.5%}.works-main{height:225px}.works-feature img{width:100%;height:225px}.works-entry{margin-bottom:20px}}::-webkit-scrollbar{width:6px;height:6px;background-color:#eee}#mo-nav::-webkit-scrollbar{width:0;opacity:0}::-webkit-scrollbar-track{background-color:#eee}::-webkit-scrollbar-thumb{background-color:#69d2e7}@keyframes poi-deg{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-webkit-keyframes poi-deg{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes elastic{0%{transform:scale(0)}55%{transform:scale(1)}70%{transform:scale(.98)}100%{transform:scale(1)}}@keyframes btn-pudding{12%,15%{transform:scale(.93,1.07)}16%,17%{transform:scale(.94,1.06)}10%,18%{transform:scale(.95,1.05)}19%{transform:scale(.96,1.04)}20%{transform:scale(.98,1.02)}21%,40%,48%{transform:scale(.99,1.01)}22%,23%,37%,39%,49%{transform:scale(1,1)}24%,34%,36%,7%{transform:scale(1.01,.99)}25%,27%,30%,33%{transform:scale(1.02,.98)}28%,29%{transform:scale(1.03,.97)}2%{transform:scale(1.16,.84)}0%{transform:scale(1.2,.8)}}@keyframes poi-face{2%,24%,80%{-webkit-transform:translate(0,1.5px) rotate(1.5deg);transform:translate(0,1.5px) rotate(1.5deg)}4%,68%,98%{-webkit-transform:translate(0,-1.5px) rotate(-.5deg);transform:translate(0,-1.5px) rotate(-.5deg)}38%,6%{-webkit-transform:translate(0,1.5px) rotate(-1.5deg);transform:translate(0,1.5px) rotate(-1.5deg)}8%,86%{-webkit-transform:translate(0,-1.5px) rotate(-1.5deg);transform:translate(0,-1.5px) rotate(-1.5deg)}10%,72%{-webkit-transform:translate(0,2.5px) rotate(1.5deg);transform:translate(0,2.5px) rotate(1.5deg)}12%,64%,78%,96%{-webkit-transform:translate(0,-.5px) rotate(1.5deg);transform:translate(0,-.5px) rotate(1.5deg)}14%,54%{-webkit-transform:translate(0,-1.5px) rotate(1.5deg);transform:translate(0,-1.5px) rotate(1.5deg)}16%{-webkit-transform:translate(0,-.5px) rotate(-1.5deg);transform:translate(0,-.5px) rotate(-1.5deg)}18%,22%{-webkit-transform:translate(0,.5px) rotate(-1.5deg);transform:translate(0,.5px) rotate(-1.5deg)}20%,36%,46%{-webkit-transform:translate(0,-1.5px) rotate(2.5deg);transform:translate(0,-1.5px) rotate(2.5deg)}26%,50%{-webkit-transform:translate(0,.5px) rotate(.5deg);transform:translate(0,.5px) rotate(.5deg)}28%{-webkit-transform:translate(0,.5px) rotate(1.5deg);transform:translate(0,.5px) rotate(1.5deg)}30%,40%,62%,76%,88%{-webkit-transform:translate(0,-.5px) rotate(2.5deg);transform:translate(0,-.5px) rotate(2.5deg)}32%,34%,66%{-webkit-transform:translate(0,1.5px) rotate(-.5deg);transform:translate(0,1.5px) rotate(-.5deg)}42%{-webkit-transform:translate(0,2.5px) rotate(-1.5deg);transform:translate(0,2.5px) rotate(-1.5deg)}44%,70%{-webkit-transform:translate(0,1.5px) rotate(.5deg);transform:translate(0,1.5px) rotate(.5deg)}48%,74%,82%{-webkit-transform:translate(0,-.5px) rotate(.5deg);transform:translate(0,-.5px) rotate(.5deg)}52%,56%,60%{-webkit-transform:translate(0,2.5px) rotate(2.5deg);transform:translate(0,2.5px) rotate(2.5deg)}58%{-webkit-transform:translate(0,.5px) rotate(2.5deg);transform:translate(0,.5px) rotate(2.5deg)}84%{-webkit-transform:translate(0,1.5px) rotate(2.5deg);transform:translate(0,1.5px) rotate(2.5deg)}90%{-webkit-transform:translate(0,2.5px) rotate(-.5deg);transform:translate(0,2.5px) rotate(-.5deg)}92%{-webkit-transform:translate(0,.5px) rotate(-.5deg);transform:translate(0,.5px) rotate(-.5deg)}94%{-webkit-transform:translate(0,2.5px) rotate(.5deg);transform:translate(0,2.5px) rotate(.5deg)}0%,100%{-webkit-transform:translate(0,0) rotate(0);transform:translate(0,0) rotate(0)}}.ex-login,.ex-register{margin:auto;width:400px;text-align:center;background-color:rgba(255,255,255,0)}.ex-login{padding:20px 0;background-color:rgba(255,255,255,0)}.ex-login p,.ex-register p{margin:1em}.ex-login-title{color:#666;font-size:20px;padding-top:25px}.ex-login-title img{width:85px;height:85px;border-radius:100%}.ex-register-title h3{padding-bottom:15px;font-size:24px;color:#666}.ex-login input,.ex-register input{width:300px;margin-bottom:6px;padding:12px 10px;border:1px #ddd solid;outline:0;border-radius:3px;font-size:16px;font:300 14px miranafont,"Hiragino Sans GB","Microsoft YaHei",STXihei,SimSun,sans-serif;-webkit-transition:.4s ease all;-moz-transition:.4s ease all;-o-transition:.4s ease all;transition:.4s ease all}.ex-login input.login-button,.ex-register input.register-button{box-shadow:none;text-shadow:none;background-color:#eee}.ex-register input.register-button{margin-bottom:20px}.ex-login input.login-button:hover,.ex-register input.register-button:hover{background-color:#E67474;border-color:#E67474;color:#fff}.admin-login-check,.user-login-check{width:100%;margin:10% 0 12%;text-align:center;font-size:16px;color:#555}.admin-login-check p,.user-login-check p{margin:.8em}.ex-login-avatar img{border-radius:100%;border:1px solid #ddd;padding:5px;width:110px;height:110px}.ex-login-username{font-size:20px}.ex-new-account{padding:45px 0}.ex-new-account a{font-size:16px}.ex-new-account a:hover{color:#E67474}.ex-logout{padding-top:1em}.ex-logout a,.ex-new-account a{color:#555;text-decoration:underline;margin:0 20px}.ex-register .user-error{text-align:left;font-size:12px;width:300px;margin:0 auto 24px;padding:8px;background:rgba(241,241,241,.5)}.register-close{margin-bottom:200px;font-size:18px}.header-user-avatar{position:relative;float:right;margin-left:20px;margin-top:22px}.header-user-avatar img{border-radius:100%;cursor:pointer}.header-user-avatar:hover .header-user-menu{display:block}.header-user-menu{position:absolute;width:110px;right:-11px;text-align:left;background:0 0;top:44px;display:none;overflow:hidden;animation:header-user-menu .4s;box-shadow:0 1px 40px -8px rgba(0,0,0,.5);border-radius:5px;text-align:center}.header-user-menu::before{content:"";position:fixed;top:46px;right:25px;margin-left:-10px;border-width:10px;border-style:solid;border-color:transparent transparent #fff transparent}.herder-user-name{font-size:12px;background:#fff;padding:10px 10px;border-radius:4px 4px 0 0}.herder-user-name-u{font-weight:700;font-size:14px;overflow:hidden;text-overflow:ellipsis;-o-text-overflow:ellipsis;white-space:nowrap}.header-user-menu .user-menu-option{padding:5px 0;background:#fff;border-radius:0 0 4px 4px;width:130px}.header-user-menu a{display:block;padding:6px 10px;margin:2px 0;width:110px;text-align:left;color:#333;font-size:13px;text-align:center}.user-menu-option a:hover{background-color:#f1f1f1}.no-logged{font-size:13px;padding:15px 10px;border-radius:4px;border:0}.no-logged a{display:initial;color:#69d2e7;font-size:14px;padding:0 5px;text-decoration:underline}@keyframes header-user-menu{0%{opacity:0;transform:translateY(-20px)}100%{opacity:1;transform:translateY(0)}}.oshimai{height:2em;width:6.11em;background:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/oshimai.svg);background-size:cover;margin:0 auto}.single-reward{position:relative;width:100%;margin:35px auto;text-align:center;z-index:999}.single-reward .reward-open{position:relative;width:40px;height:40px;font-size:18px;padding:7px;color:#fff;text-align:center;display:inline-block;border-radius:100%;background:#d34836;cursor:pointer}.single-reward .reward-main{position:absolute;top:40px;left:-157px;margin:0;padding:15px 0 0;width:355px;background:0 0;display:none;animation:main .4s}.reward-open:hover .reward-main{display:block}.single-reward .reward-row{margin:0 auto;padding:20px 15px 10px;background:#f5f5f5;display:inline-block;border-radius:4px;cursor:auto}.single-reward .reward-row:before{content:"";width:0;height:0;border-left:13px solid transparent;border-right:13px solid transparent;border-bottom:13px solid #F5F5F5;position:absolute;top:2px;left:0;right:0;margin:0 auto}.single-reward .reward-row li{list-style-type:none;padding:0 12px;display:inline-block}.reward-row li img{width:130px;max-width:130px;border-radius:3px;position:relative}.reward-row li::after{display:block;padding:5px 0 0;font-size:13px;color:#555}.alipay-code:after{content:"支付宝"}.wechat-code:after{content:"微信"}.sm{cursor:wait}.botui-container{font-size:14px;background-color:rgba(255,255,255,0)}.botui-messages-container{padding:10px 20px}.botui-actions-container{padding:10px 20px}.botui-message{min-height:30px}.botui-message-content{padding:7px 13px;border-radius:15px;color:#595a5a;background-color:#ebebeb}.botui-message-content.human{color:#f7f8f8;background-color:#919292}.botui-message-content.text{line-height:1.3}.botui-message-content.loading{background-color:rgba(206,206,206,.5);line-height:1.3;text-align:center}.botui-message-content.embed{padding:5px;border-radius:5px}.botui-message-content-link{color:#919292}.botui-actions-text-input{border:0;outline:0;border-radius:0;padding:5px 7px;background-color:transparent;color:#595a5a;border-bottom:1px solid #919292}.botui-actions-text-submit{color:#fff;width:30px;padding:5px;height:30px;line-height:1;border-radius:50%;border:1px solid #919292;background:#777979}.botui-actions-buttons-button{border:0;color:#fff;line-height:1;cursor:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/No_Disponible.cur),auto;font-size:14px;font-weight:500;padding:7px 15px;border-radius:4px;background:#777979;box-shadow:2px 3px 4px 0 rgba(0,0,0,.25)}.poptitle{width:100%;height:100%;line-height:3;border-top-left-radius:6px;border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;background-color:rgba(255,255,255,.7)}@media (min-width:400px){.poptitle{width:400px;height:100%;margin:0 auto;border-top-left-radius:6px;border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;background-color:rgba(255,255,255,.7)}}.popfooter{width:100%;height:100%;line-height:1;background-color:rgba(255,255,255,.7)}@media (min-width:400px){.popfooter{width:400px;height:100%;margin:0 auto;background-color:rgba(255,255,255,.7)}}.popcontainer{width:100%;height:100%;line-height:1}@media (min-width:400px){.popcontainer{height:100%;margin:0 auto}}.slide-fade-enter-active{transition:all .3s ease}.slide-fade-enter,.slide-fade-leave-to{opacity:0;transform:translateX(-10px)}.dot{width:.5rem;height:.5rem;border-radius:.5rem;display:inline-block;background-color:#919292}.dot:nth-last-child(1){margin-left:.3rem;animation:loading .6s .3s linear infinite}.dot:nth-last-child(2){margin-left:.3rem;animation:loading .6s .2s linear infinite}.dot:nth-last-child(3){animation:loading .6s .1s linear infinite}@keyframes loading{0{transform:translate(0,0);background-color:#ababab}25%{transform:translate(0,-3px)}50%{transform:translate(0,0);background-color:#ababab}75%{transform:translate(0,3px)}100%{transform:translate(0,0)}}a.botui-message-content-link:focus{outline:thin dotted}a.botui-message-content-link:focus:active,a.botui-message-content-link:focus:hover{outline:0}form.botui-actions-text{margin:0}button.botui-actions-buttons-button,input.botui-actions-text-input{margin:0;font-size:100%;line-height:normal;vertical-align:baseline}button.botui-actions-buttons-button::-moz-focus-inner,input.botui-actions-text-input::-moz-focus-inner{border:0;padding:0}button.botui-actions-buttons-button{cursor:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/No_Disponible.cur),auto;-webkit-appearance:button}.botui-app-container{width:100%;height:100%;line-height:1}@media (min-width:400px){.botui-app-container{width:400px;height:500px;margin:0 auto}}.botui-container{width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.botui-message{margin:10px 0;min-height:20px}.botui-message-content{width:auto;max-width:85%;display:inline-block}.botui-message-content.human{float:right;margin-bottom:12.2px}.botui-message-content iframe{width:100%}.botui-message-content-image{margin:5px 0;display:block;max-width:200px;max-height:200px}.botui-message-content-link{text-decoration:underline}.botui-actions-buttons-button+.botui-actions-buttons-button{margin-left:10px}@media (min-width:400px){.botui-actions-text-submit{display:none}}.load-button{width:200px;height:60px;margin:auto;cursor:pointer;perspective:500px;-webkit-perspective:500px}.load-button div{height:100%;transform-style:preserve-3d;-webkit-transform-style:preserve-3d;transition:.25s;-webkit-transition:.25s}.load-button:hover div{transform:rotateX(-90deg)}.load-button span{width:100%;height:100%;position:absolute;box-sizing:border-box;border:5px solid #d34836;line-height:50px;font-size:17pt;text-align:center;text-transform:uppercase}.load-button span:nth-child(1){color:#d34836;transform:translate3d(0,0,30px);-webkit-transform:translate3d(0,0,30px)}.load-button span:nth-child(2){color:#fff;background:#d34836;transform:rotateX(90deg) translate3d(0,0,30px);-webkit-transform:rotateX(90deg) translate3d(0,0,30px)}.logolink a{color:#464646;float:left;font-size:20px;font-weight:800;height:56px;line-height:56px;padding-left:35px;padding-right:15px;padding-top:11px;text-decoration-line:none}.forgetmenot input[type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 4px 0 0;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out}.forgetmenot input[type=checkbox]:checked:before{content:"✔";margin:-3px 0 0 -4px;color:#1e8cbe}.forgetmenot input[type=checkbox]:checked:before,input[type=radio]:checked:before{float:left;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.forgetmenot input[type=checkbox]:checked:before{content:"✔";margin:-3px 0 0 -4px;color:#1e8cbe}.forgetmenot input[type=checkbox]:checked:before,input[type=radio]:checked:before{float:left;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.prpr{position:fixed;bottom:0;left:0;z-index:99;font-size:0;transition:all .3s ease-in-out;-webkit-transform:translateY(3px);transform:translateY(3px);cursor:grab;user-select:none}.prpr:hover{-webkit-transform:translateY(0);transform:translateY(0)}.prpr:active{cursor:grabbing}@media (max-width:860px){.prpr{transform:scale(.8) translate(-30px,31px)}.prpr:hover{-webkit-transform:scale(.8) translate(-30px,31px);transform:scale(.8) translate(-30px,31px)}}@media (max-width:560px){.prpr{transform:scale(.5) translate(-150px,125px)}.prpr:hover{-webkit-transform:scale(.5) translate(-150px,125px);transform:scale(.5) translate(-150px,125px)}}.prpr #live2d{position:relative;z-index:99}.mashiro-tips{opacity:0;width:250px;height:auto;min-height:70px;margin:-20px 20px;padding:5px 10px;border-radius:12px;box-sizing:border-box;box-shadow:0 0 2px 0 rgba(0,0,0,.12),0 2px 2px 0 rgba(0,0,0,.24);transition:box-shadow .2s ease;background:#fff;color:#212121;font-size:12px;text-overflow:ellipsis;overflow:hidden;position:absolute;animation-delay:5s;animation-duration:50s;animation-iteration-count:infinite;animation-name:shake;animation-timing-function:ease-in-out}@keyframes shake{2%{transform:translate(.5px,-1.5px) rotate(-.5deg)}4%{transform:translate(.5px,1.5px) rotate(1.5deg)}6%{transform:translate(1.5px,1.5px) rotate(1.5deg)}8%{transform:translate(2.5px,1.5px) rotate(.5deg)}10%{transform:translate(.5px,2.5px) rotate(.5deg)}12%{transform:translate(1.5px,1.5px) rotate(.5deg)}14%{transform:translate(.5px,.5px) rotate(.5deg)}16%{transform:translate(-1.5px,-.5px) rotate(1.5deg)}18%{transform:translate(.5px,.5px) rotate(1.5deg)}20%{transform:translate(2.5px,2.5px) rotate(1.5deg)}22%{transform:translate(.5px,-1.5px) rotate(1.5deg)}24%{transform:translate(-1.5px,1.5px) rotate(-.5deg)}26%{transform:translate(1.5px,.5px) rotate(1.5deg)}28%{transform:translate(-.5px,-.5px) rotate(-.5deg)}30%{transform:translate(1.5px,-.5px) rotate(-.5deg)}32%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}34%{transform:translate(2.5px,2.5px) rotate(-.5deg)}36%{transform:translate(.5px,-1.5px) rotate(.5deg)}38%{transform:translate(2.5px,-.5px) rotate(-.5deg)}40%{transform:translate(-.5px,2.5px) rotate(.5deg)}42%{transform:translate(-1.5px,2.5px) rotate(.5deg)}44%{transform:translate(-1.5px,1.5px) rotate(.5deg)}46%{transform:translate(1.5px,-.5px) rotate(-.5deg)}48%{transform:translate(2.5px,-.5px) rotate(.5deg)}50%{transform:translate(-1.5px,1.5px) rotate(.5deg)}52%{transform:translate(-.5px,1.5px) rotate(.5deg)}54%{transform:translate(-1.5px,1.5px) rotate(.5deg)}56%{transform:translate(.5px,2.5px) rotate(1.5deg)}58%{transform:translate(2.5px,2.5px) rotate(.5deg)}60%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}62%{transform:translate(-1.5px,.5px) rotate(1.5deg)}64%{transform:translate(-1.5px,1.5px) rotate(1.5deg)}66%{transform:translate(.5px,2.5px) rotate(1.5deg)}68%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}70%{transform:translate(2.5px,2.5px) rotate(.5deg)}72%{transform:translate(-.5px,-1.5px) rotate(1.5deg)}74%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}76%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}78%{transform:translate(-1.5px,2.5px) rotate(.5deg)}80%{transform:translate(-1.5px,.5px) rotate(-.5deg)}82%{transform:translate(-1.5px,.5px) rotate(-.5deg)}84%{transform:translate(-.5px,.5px) rotate(1.5deg)}86%{transform:translate(2.5px,1.5px) rotate(.5deg)}88%{transform:translate(-1.5px,.5px) rotate(1.5deg)}90%{transform:translate(-1.5px,-.5px) rotate(-.5deg)}92%{transform:translate(-1.5px,-1.5px) rotate(1.5deg)}94%{transform:translate(.5px,.5px) rotate(-.5deg)}96%{transform:translate(2.5px,-.5px) rotate(-.5deg)}98%{transform:translate(-1.5px,-1.5px) rotate(-.5deg)}0%,100%{transform:translate(0,0) rotate(0)}}.live2d-tool{position:fixed;bottom:0;left:0;width:auto;height:auto;z-index:100;border-radius:5px;font-size:13px;cursor:pointer;font-family:Ubuntu}@media (min-width:861px){.live2d-tool{border-radius:0 5px 5px 0;width:35px;left:-17px;color:#fff;font-size:13px;padding:5px 0;padding-top:5px;padding-right:0;padding-bottom:5px;padding-left:17px;font-weight:700;z-index:99;visibility:visible;writing-mode:vertical-rl;transiton-property:left,bottom;transition-duration:.5s,.5s}.live2d-tool:hover{left:0}}@media (max-width:860px){.live2d-tool{padding:0 5px}}@media screen and (-webkit-min-device-pixel-ratio:0){.live2d-tool{position:fixed;bottom:0;left:0;width:auto;height:auto;z-index:100;border-radius:5px;font-size:13px;cursor:pointer}@media (min-width:861px){.live2d-tool{border-radius:0 5px 5px 0;width:35px;margin-left:-35px;color:#fff;font-size:13px;padding:5px 0;padding-top:5px;padding-right:0;padding-bottom:5px;padding-left:17px;font-weight:700;z-index:99;writing-mode:vertical-rl;transiton-property:margin-left,bottom;transition-duration:.5s,.5s}.live2d-tool:hover{margin-left:-17px}}}@supports (-ms-ime-align:auto){.live2d-tool{margin-left:0;left:-17px;transiton-property:left,bottom}.live2d-tool:hover{margin-left:0}}.live2d-tool .keys{position:relative}.hide-live2d{visibility:visible}.switch-live2d{visibility:hidden}.save-live2d{visibility:hidden}@media (min-width:861px){.hide-live2d{background-color:orange;bottom:156px;visibility:visible;min-height:38.75px}.switch-live2d{background-color:#F7BB4D;bottom:105px;visibility:visible;min-height:51px}.save-live2d{background-color:#EED099;bottom:66px;visibility:visible;min-height:39.3px}}.hide-live2d-tool{bottom:15px}.ap-hover,.aplayer-icon,.aplayer-miniswitcher,.live2d-tool{border-radius:0 6px 6px 0!important}.video-container{position:relative;padding-bottom:56.25%;padding-top:30px;height:0;overflow:hidden}.video-container embed,.video-container iframe,.video-container object{position:absolute;top:0;left:0;width:100%;height:100%}#Snow{position:fixed;top:0;left:0;width:100%;height:100%;z-index:99999;background:rgba(125,137,95,0);pointer-events:none}#night-mode-cover{position:fixed;top:0;left:0;width:100%;height:100%;z-index:99999;background:rgba(86,86,86,.2);pointer-events:none;visibility:hidden}.changeSkin{position:fixed;bottom:0;right:-600px;width:auto;height:auto;z-index:99;font-family:Ubuntu;padding:10px 20px;transiton-property:right;transition-duration:.3s,.3s}.changeSkin .keys{position:relative;z-index:99}.changeSkin .keys span{cursor:pointer}.changeSkin-gear{position:fixed;bottom:0;left:5px;width:auto;height:auto;z-index:99;white-space:nowrap;padding:10px 10px;cursor:pointer;border-radius:10px 10px 0 0}.changeSkin .keys{position:relative;z-index:99}.changeSkin .keys span{cursor:pointer}.changeSkin .close-skinMenu{position:relative;z-index:99;cursor:pointer}.keys-line-add{text-align:right;margin-right:22px}@media (max-width:800px){.changeSkin-gear{visibility:hidden}.changeSkin-gear span::before{content:""}.changeSkin i{font-size:20px}.changeSkin-gear i{font-size:20px}}.changeSkin-gear span:before{content:""}@media (max-width:800px){.changeSkin-gear span::before{content:""}.changeSkin i{font-size:20px}.changeSkin-gear i{font-size:20px}}.img-preload{visibility:hidden;width:0;height:0}@-webkit-keyframes rotating{from{-webkit-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotating{from{-ms-transform:rotate(0);-moz-transform:rotate(0);-webkit-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}to{-ms-transform:rotate(360deg);-moz-transform:rotate(360deg);-webkit-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}.rotating{-webkit-animation:rotating 3s linear infinite;-moz-animation:rotating 3s linear infinite;-ms-animation:rotating 3s linear infinite;-o-animation:rotating 3s linear infinite;animation:rotating 3s linear infinite}.inline-block{display:inline-block}.block{display:block}.center-text{margin:auto;font-family:Ubuntu,sans-serif;font-size:80px;text-transform:uppercase}.glitch{position:relative;color:#fff;mix-blend-mode:lighten}.glitch:after,.glitch:before{content:attr(data-text);position:absolute;top:0;width:100%;background:rgba(0,0,0,0);clip:rect(0,0,0,0)}.glitch:before{left:-1px;text-shadow:1px 0 #ff3f1a}.glitch:after{left:1px;text-shadow:-1px 0 #00a7e0}.glitch:hover:before{text-shadow:4px 0 #ff3f1a;animation:glitch-loop-1 .8s infinite ease-in-out alternate-reverse}.glitch:hover:after{text-shadow:-5px 0 #00a7e0;animation:glitch-loop-2 .8s infinite ease-in-out alternate-reverse}@-webkit-keyframes glitch-loop-1{0%{clip:rect(36px,9999px,9px,0)}25%{clip:rect(25px,9999px,99px,0)}50%{clip:rect(50px,9999px,102px,0)}75%{clip:rect(30px,9999px,92px,0)}100%{clip:rect(91px,9999px,98px,0)}}@keyframes glitch-loop-1{0%{clip:rect(36px,9999px,9px,0)}25%{clip:rect(25px,9999px,99px,0)}50%{clip:rect(50px,9999px,102px,0)}75%{clip:rect(30px,9999px,92px,0)}100%{clip:rect(91px,9999px,98px,0)}}@-webkit-keyframes glitch-loop-2{0%{top:-1px;left:1px;clip:rect(65px,9999px,119px,0)}25%{top:-6px;left:4px;clip:rect(79px,9999px,19px,0)}50%{top:-3px;left:2px;clip:rect(68px,9999px,11px,0)}75%{top:0;left:-4px;clip:rect(95px,9999px,53px,0)}100%{top:-1px;left:-1px;clip:rect(31px,9999px,149px,0)}}@keyframes glitch-loop-2{0%{top:-1px;left:1px;clip:rect(65px,9999px,119px,0)}25%{top:-6px;left:4px;clip:rect(79px,9999px,19px,0)}50%{top:-3px;left:2px;clip:rect(68px,9999px,11px,0)}75%{top:0;left:-4px;clip:rect(95px,9999px,53px,0)}100%{top:-1px;left:-1px;clip:rect(31px,9999px,149px,0)}}.bb-comment{border:1px solid #fb7299;min-width:30px;display:inline-block;text-align:center;font-size:12px;color:#fb7299;border-radius:3px;font-weight:400}.mashiro-author-info{background:url(//static.mashiro.top/wp-content/themes/Sakura/images/LOGO-Unicorn-Gradient.svg);width:200px;height:200px;margin:auto}.itempic{min-height:280px;max-height:300px;background-position:center center;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover}.finish-icon-container{font-size:1rem;display:-webkit-box;display:box;display:-webkit-flex;display:flex;-webkit-box-align:center;box-align:center;-webkit-align-items:center;align-items:center}.finish-icon-text{margin-right:8px}.finish-icon{vertical-align:text-bottom}progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;background-size:auto;height:24px;width:100%}.skill-list{list-style:none;margin:0;padding-top:25px}.skill{margin-bottom:1em;position:relative}.skill div{color:#fff;line-height:1;position:absolute;top:4px;font-size:1em;margin-top:0;margin-bottom:0;text-shadow:0 0 1px rgba(0,0,0,.22);width:100%;text-align:center}.skill ::-webkit-progress-value{-webkit-animation:bar-fill 2s;width:0}.skill-1::-webkit-progress-value{background:#ff9e2c}.skill-1::-moz-progress-bar{background:#ff9e2c}@-webkit-keyframes bar-fill{0%{width:0}}@keyframes bar-fill{0%{width:0}}.art .art-content #archives a:before,.art .art-content .al_mon_list li:before{content:none}#archives ul{list-style:none;margin-bottom:0;left:-45px}#archives li{list-style:none}#archives li>ul,li>ol{margin-left:-2.7em}#archives h3{margin-top:0;margin-bottom:0}.art-content #archives .al_mon_list{position:relative;padding:10px 0;display:inline-block;vertical-align:middle}.art .art-content #archives a{color:#000}.art .art-content #archives a:hover{color:orange}.art .art-content #archives .al_year{padding-left:100px}.art .art-content .al_mon_list .al_post_list>li,.art-content #archives .al_mon_list .al_mon{position:relative}.art-content #archives .al_mon_list .al_mon,.art-content #archives .al_mon_list span{padding:0;border-radius:0;margin:0;color:#000;background:0 0;font-weight:400}.art .art-content #archives a{font-weight:400}.art .art-content .al_mon_list{width:100%}.art .art-content .al_mon_list .al_post_list>li:before{position:absolute;left:116px;background:#fff;height:12px;width:12px;border-radius:6px;top:6px;content:""}.art .art-content .al_mon_list .al_post_list>li:after{position:absolute;left:118px;background:#6ecaf5;height:8px;width:8px;border-radius:6px;top:8px;content:""}.art-content #archives .al_mon_list .al_mon:before{position:absolute;left:113px;background:#fff;height:18px;width:18px;border-radius:9px;top:3px;content:""}.art-content #archives .al_mon_list .al_mon:after{position:absolute;left:116px;background:#6ecaf5;height:12px;width:12px;border-radius:6px;top:6px;content:""}.art .art-content .al_mon_list .al_post_list>li{padding-left:140px}.art-content #archives .al_mon,.art-content #archives .al_mon_list .al_post_list{display:block}.art-content #archives .al_mon_list:before{max-height:100%;height:100%;width:4px;background:#6ecaf5;position:absolute;left:120px;content:"";top:0}.art .art-content .al_mon_list .al_post_list>li:before,.art-content #archives .al_mon_list .al_mon:before{-webkit-box-shadow:1px 1px 1px #bbb;box-shadow:1px 1px 1px #bbb}.art .art-content .al_mon_list .al_post_list>li:after,.art-content #archives .al_mon_list .al_mon:after{background:#0bf}.toc-container{z-index:98;width:200px;height:100%;background-color:rgba(255,255,255,0);transform:translateX(0);right:calc((100% - 950px - 250px)/ 2);position:absolute!important;top:480px;position:absolute;padding-top:10px;padding-bottom:10px}.toc{position:-webkit-sticky;position:sticky;top:100px}@media (max-width:1200px){.toc-container{display:none}}.toc{overflow-y:auto}.toc>.toc-list{overflow:hidden;position:relative}.toc>.toc-list li{list-style:none}.toc-list{margin:0;padding-left:10px}a.toc-link{color:currentColor;height:100%}.is-collapsible{max-height:1000px;overflow:hidden;transition:all .3s ease-in-out}.is-collapsed{max-height:0}.is-position-fixed{position:fixed!important;top:0}.is-active-link{font-weight:700}.toc-link::before{background-color:#EEE;content:' ';display:inline-block;height:inherit;left:0;margin-top:-1px;position:absolute;width:2px}.is-active-link::before{background-color:orange!important}.flipx{-moz-transform:scaleX(-1);-webkit-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH}.flipy{-moz-transform:scaleY(-1);-webkit-transform:scaleY(-1);-o-transform:scaleY(-1);transform:scaleY(-1);filter:FlipV}.flipx-v2{transform:rotateY(180deg)}.flipy-v2{transform:rotateX(180deg)}.ex-login,.ex-register{width:auto!important}.bili-container,.tieba-container{padding-left:16px}.tieba-container span{width:32px;height:32px}.tieba-container img{width:32px;height:32px;margin:7px}.tieba-container img:hover{background-color:rgba(245,245,245,.8);border-radius:5px}.emotion-box{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;display:none}.emotion-inline{padding-left:0!important;padding-right:0!important}.emotion-item{margin:6px;display:inline-block;width:32px;height:32px;overflow:hidden;border-radius:4px;margin-bottom:-8px}.emotion-secter{margin:12px 12px 0 0}.emotion-item .img{-webkit-animation:im-emotion-step 1.08s steps(27) infinite;animation:im-emotion-step 1.08s steps(27) infinite;animation-duration:1.08s;animation-timing-function:steps(27)}.emotion-item .img{width:32px;height:864px;max-width:32px;background:top/32px no-repeat;background-image:none}@-webkit-keyframes im-emotion-step{0%{-webkit-transform:translateY(0);transform:translateY(0)}to{-webkit-transform:translateY(-100%);transform:translateY(-100%)}}@keyframes im-emotion-step{0%{-webkit-transform:translateY(0);transform:translateY(0)}to{-webkit-transform:translateY(-100%);transform:translateY(-100%)}}.emotion-select-parent{background-size:cover}.emotion-select-child{display:none}.emotion-select-parent:hover{background-image:none!important;background-color:rgba(245,245,245,.8);border-radius:5px}.emotion-select-parent:hover .emotion-select-child{display:block}#emotion-toggle{text-align:center;margin-bottom:5px}.emotion-toggle-on{display:none}.motion-switcher-table{border-collapse:collapse;width:100%;margin:0;table-layout:fixed}.motion-switcher-table td,.motion-switcher-table th{padding:8px;text-align:center;border-radius:5px}.motion-switcher-table th:hover{background-color:rgba(245,245,245,.5);color:orange}.motion-switcher-table .on-hover{color:orange}.motion-container{height:110px;overflow:auto;margin-bottom:5px;border-radius:5px}@media (max-width:860px){.bili-container,.tieba-container{padding-left:0}.emotion-item{transform:scale(.6);margin-bottom:-10px}.tieba-container img,.tieba-container span{transform:scale(.6);margin-bottom:-10px}.emotion-secter{margin:0}.emotion-select-parent:hover{background-image:none!important;-ms-transform:scale(.6,.6);-webkit-transform:scale(.6,.6);transform:scale(.6,.6)}}.menhera-container .emoji-item{padding:3px 5px;margin:3px 3px;display:inline-block;border-radius:4px;color:#333}.menhera-container .emoji-item:hover{background-color:rgba(245,245,245,.8)}#emotion-toggle,.emoji-item,.emotion-box,.emotion-item,.on-hover,.tieba-container span{cursor:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/No_Disponible.cur),auto}.alignright{width:auto!important}.no-select{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.scrollbar{position:fixed;top:0;height:3px;background:#BEBEBE;transiton-property:width,background;transition-duration:1s,1s;z-index:99999}#footer-sponsor{font-size:9px}@media (max-width:860px){#footer-sponsor{margin-bottom:-20px}}.comment-user-avatar{position:absolute;display:inline-block;float:left;width:64px;height:64px;margin-top:10px;pointer-events:none}.comment-user-avatar img{width:100%;height:100%;border-radius:50%}.comment-user-avatar .socila-check{display:none;width:1.5em;height:1.5em;font-size:1em;line-height:1.5em;text-align:center;color:#fff;border-radius:50%;position:absolute;margin:-28px 0 0 42px}.qq-check{background-color:#99ce00}.gravatar-check{background-color:#1e8cbe;-ms-transform:rotate(270deg);-webkit-transform:rotate(270deg);transform:rotate(270deg)}@media (max-width:625px){.comment-user-avatar{padding-top:10px;width:45px;height:55px;right:36px}.comment-user-avatar .socila-check{width:1.5em;height:1.5em;font-size:.5em;line-height:1.5em;margin:-40% 0 0 77%}}.popup{position:relative;display:inline-block;cursor:pointer}.cmt-popup{margin:0 0 40px 1%;--widthA:97%;--widthB:calc(var(--widthA) - 71px);--widthC:calc(var(--widthB) / 3);width:var(--widthC);margin-top:10px}.cmt-author{margin-left:70px}@media (max-width:625px){.cmt-popup{margin:0;width:100%;margin-top:15px}.cmt-author{margin-top:10px;margin-left:0}}.popup .popuptext{visibility:hidden;width:160px;background-color:#555;color:#fff;text-align:center;border-radius:6px;padding:8px 3px;position:absolute;z-index:1;bottom:110%;left:50%;margin-left:-80px}.popup .popuptext::after{content:"";position:absolute;top:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#555 transparent transparent transparent}.popup .insert-img-popuptext{visibility:hidden;width:66px;background-color:#555;color:#fff;text-align:center;border-radius:6px;padding:8px 3px;position:absolute;z-index:1;bottom:9%;left:10%;margin-left:-80px}.popup .insert-img-popuptext::after{content:"";position:absolute;top:33%;left:109%;margin-left:-7px;border-width:7px;border-style:solid;border-color:transparent transparent transparent #555}.popup .show{visibility:visible;-webkit-animation:fadeIn 1s;animation:fadeIn 1s}@-webkit-keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}.insert-image-tips{float:right;text-align:center;width:46px;margin:0;padding:12px 16px;text-transform:none;color:#535a63;background:0 0;-webkit-transition:all .1s ease-out;-moz-transition:all .1s ease-out;transition:all .1s ease-out;box-shadow:none;border:1px solid #ccc;text-shadow:none;font-size:14px;height:46px;border-radius:3px;cursor:pointer}.insert-image-tips:hover{color:orange;border:1px solid orange}.insert-image-button{opacity:0;width:46px!important;height:46px!important;margin:0!important;padding:0!important;float:right;transform:translateY(-46px);cursor:pointer}.insert-image-tips-hover{color:orange;border:1px solid orange}.upload-image-preview{display:inline-block;height:70px;margin-right:3px;border:1px solid #ddd;border-radius:4px;padding:3px;cursor:pointer}.comment_inline_img{display:inline-block;height:150px;margin-right:3px;border:1px solid #ddd;border-radius:4px;padding:3px;cursor:pointer}.top-feature-row{width:100%;height:auto;margin-top:55px}.top-feature-v2{display:inline-block}.the-feature{position:relative;-webkit-transition:all .35s ease-in-out;-moz-transition:all .35s ease-in-out;transition:all .35s ease-in-out}.the-feature,.the-feature *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.the-feature a{color:#333}.the-feature a:hover{text-decoration:none}.the-feature img{height:160px;width:257px}.the-feature.from_left_and_right{position:relative;height:160px;width:253px;box-shadow:1px 1px 3px rgba(0,0,0,.3);overflow:hidden;border-radius:10px}.the-feature.from_left_and_right .img{-webkit-transition:all .35s ease-in-out;-moz-transition:all .35s ease-in-out;transition:all .35s ease-in-out;-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);-o-transform:scale(1);transform:scale(1)}.the-feature.from_left_and_right .info{position:absolute;top:0;bottom:0;left:0;right:0;text-align:center;-webkit-backface-visibility:hidden;backface-visibility:hidden;background:#333;background:rgba(0,0,0,.6);visibility:hidden;opacity:0;-webkit-transition:all .35s ease-in-out;-moz-transition:all .35s ease-in-out;transition:all .35s ease-in-out}.the-feature.from_left_and_right .info h3{text-transform:uppercase;color:#fff;text-align:center;font-size:17px;padding:10px;background:#111;margin:30px 0 0 0;-webkit-transition:all .35s ease-in-out;-moz-transition:all .35s ease-in-out;transition:all .35s ease-in-out;-webkit-transform:translateX(-100%);-moz-transform:translateX(-100%);-ms-transform:translateX(-100%);-o-transform:translateX(-100%);transform:translateX(-100%)}.the-feature.from_left_and_right .info p{font-style:italic;font-size:12px;position:relative;color:#bbb;padding:20px 20px 20px;text-align:center;-webkit-transition:all .35s .1s linear;-moz-transition:all .35s .1s linear;transition:all .35s .1s linear;-webkit-transform:translateX(100%);-moz-transform:translateX(100%);-ms-transform:translateX(100%);-o-transform:translateX(100%);transform:translateX(100%)}.the-feature.from_left_and_right a:hover .img{-webkit-transform:scale(1.2);-moz-transform:scale(1.2);-ms-transform:scale(1.2);-o-transform:scale(1.2);transform:scale(1.2)}.the-feature.from_left_and_right a:hover .info{visibility:visible;opacity:1}.the-feature.from_left_and_right a:hover .info h3,.the-feature.from_left_and_right a:hover .info p{-webkit-transform:translateX(0);-moz-transform:translateX(0);-ms-transform:translateX(0);-o-transform:translateX(0);transform:translateX(0)}.highlight-wrap:before{content:" ";position:absolute;-webkit-border-radius:50%;border-radius:50%;background:#fc625d;width:12px;height:12px;left:20px;margin-top:-20px;-webkit-box-shadow:20px 0 #fdbc40,40px 0 #35cd4b;box-shadow:20px 0 #fdbc40,40px 0 #35cd4b;z-index:2}.highlight-wrap{background:#21252b;border-radius:5px;font:15px/22px "Microsoft YaHei",Arial,Sans-Serif;line-height:1.6;margin-bottom:1.6em;max-width:100%;overflow:auto;text-shadow:none;color:#000;padding-top:30px;box-shadow:0 10px 30px 0 rgba(0,0,0,.4)}.hljs-ln-line span::-moz-selection,.hljs-ln-line::-moz-selection{background:#fff;color:#21252b}.hljs-ln-line span::selection,.hljs-ln-line::selection{background:#fff;color:#21252b}.highlight-wrap code::-webkit-scrollbar{height:10x!important;width:10x!important;background-color:#1d1f21!important}.highlight-wrap code::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3)!important;border-radius:10px!important;background-color:#21252b!important}.highlight-wrap code::-webkit-scrollbar-thumb{border-radius:10px!important;-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.5)!important;background-color:#21252b!important}.highlight-wrap code{background:#1d1f21;color:#fff;word-break:break-word;font-family:'Source Code Pro',monospace,Helvetica,Tahoma,Arial,STXihei,"STHeiti Light","Microsoft YaHei",sans-serif;padding:2px;text-shadow:none;border-radius:0 0 5px 5px;cursor:url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/cursor/texto.cur),auto}.highlight-wrap code[data-rel]:before{color:#fff;content:attr(data-rel);height:38px;line-height:38px;background:#21252b;font-size:16px;position:absolute;margin-top:-35px;left:0;width:100%;font-family:Ubuntu,sans-serif;font-weight:700;padding:0 80px;text-indent:15px;text-align:center;float:left;z-index:1;border-radius:5px 5px 0 0;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;pointer-events:none}.hljs{display:block;overflow-x:auto;padding:.5em;color:#abb2bf;background:rgba(254,250,199,.5);border-radius:10px}.hljs-comment,.hljs-quote{color:#888f96;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-built_in,.hljs-class .hljs-title{color:#e6c07b}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}.hljs-ln{margin:6px 0 0 0!important}td.hljs-ln-numbers{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-align:center;color:#888f96;background:#1d1f21;font-family:'Source Code Pro',monospace,Helvetica,Tahoma,Arial,STXihei,"STHeiti Light","Microsoft YaHei",sans-serif;vertical-align:top;position:absolute;left:0;width:30px}.hljs-ln-code .hljs-ln-line{margin-left:25px;padding-left:5px}.hljs-ln-code .hljs-ln-line:hover{background-color:rgba(255,255,255,.1)}.code-block-fullscreen{position:fixed;top:0;left:0;width:100%;height:100%;min-width:100%;z-index:9999999;margin:0;animation:elastic 1s}.code-block-fullscreen code{--widthA:100%;--widthB:calc(var(--widthA) - 30px);height:var(--widthB);min-height:99%;overflow-y:hidden;overflow-x:auto;height:auto}.code-block-fullscreen-html-scroll{overflow:hidden}.chinese-font{font-family:'Merriweather Sans',Helvetica,Tahoma,Arial,'PingFang SC','Hiragino Sans GB','Microsoft Yahei','WenQuanYi Micro Hei',sans-serif}.chinese-tranditional-font{font-family:Helvetica,Tahoma,Arial,"文泉驛正黑","WenQuanYi Zen Hei","儷黑 Pro","LiHei Pro","微軟正黑體","Microsoft JhengHei","標楷體",DFKai-SB,sans-serif}.japanese-font{font-family:游ゴシック体,'Yu Gothic',YuGothic,'ヒラギノ角ゴシック Pro','Hiragino Kaku Gothic Pro',メイリオ,Meiryo,Osaka,'MS Pゴシック','MS PGothic',sans-serif}.english-serif{font-family:'Noto Serif CJK SC','Noto Serif CJK',serif}.code-font{font-family:'Source Code Pro',monospace}.Ubuntu-font{font-family:Ubuntu,sans-serif}.serif{font-family:'Source Han Serif SC','Source Han Serif',source-han-serif-sc,'PT Serif','SongTi SC','MicroSoft Yahei',Georgia,serif}@media (max-width:860px){.serif{font-family:'Merriweather Sans',Helvetica,Tahoma,Arial,'PingFang SC','Hiragino Sans GB','Microsoft Yahei','WenQuanYi Micro Hei',sans-serif}}.skin-menu{position:fixed;bottom:50px;left:10px;height:auto;width:220px;border-radius:5px;background-color:#fff;box-shadow:0 1px 40px -8px rgba(0,0,0,.5);z-index:99;font-family:Ubuntu,sans-serif;transform:scaleX(0);transiton-property:transform,background;transition-duration:.3s,.3s}.skin-menu.show{transform:scaleX(1)}.skin-menu::after{content:"";position:absolute;bottom:-20px;left:50%;margin-left:-10px;border-width:10px;border-style:solid;border-color:#fff transparent transparent transparent}.skin-menu .row-container{height:auto;margin:0;padding:0;text-align:center}.skin-menu .row-container .menu-list{display:block;text-align:center;padding:0;margin:10px auto}.menu-list li{display:inline-block;margin:6px;line-height:36px;width:36px;background-color:#f5f5f5;border-radius:50%;cursor:pointer}.menu-list li:hover{background-color:#fc3;color:#fff}.skin-menu .row-container.font-family-controls{padding:3px 12px 16px 12px}.font-family-controls button{display:inline-block;border-style:none;border-radius:5px;padding:5px 5px;height:40px;width:calc(50% - 10px);font-size:15px;font-weight:400;text-align:center;white-space:nowrap;vertical-align:middle;margin:0 4px;box-shadow:none;background-color:#f5f5f5;cursor:pointer}.font-family-controls button.selected{background-color:#fc3;color:#fff}.control-btn-serif{font-family:'Noto Serif CJK SC','Noto Serif CJK',serif}.control-btn-sans-serif{font-family:Ubuntu,sans-serif}.aplayer{background:rgba(255,255,255,.3);font-family:'Noto Serif CJK SC','Noto Serif CJK','Source Han Serif SC','Source Han Serif',source-han-serif-sc,'PT Serif','SongTi SC','MicroSoft Yahei',Georgia,serif}.aplayer .aplayer-lrc::before{background:rgba(255,255,255,0);filter:none}.aplayer .aplayer-lrc::after{background:rgba(255,255,255,0);filter:none}.aplayer{box-shadow:0 0 0 1px #eee;border-radius:3px;margin:15px 0}.aplayer .aplayer-info{padding:9px 7px 0 10px}.aplayer .aplayer-info .aplayer-controller .aplayer-bar-wrap{margin-left:1px;padding-right:3px}.aplayer .aplayer-info .aplayer-controller .aplayer-bar-wrap .aplayer-bar,.aplayer .aplayer-info .aplayer-controller .aplayer-bar-wrap .aplayer-bar .aplayer-loaded,.aplayer .aplayer-info .aplayer-controller .aplayer-bar-wrap .aplayer-bar .aplayer-played{height:6px;border-radius:10px}.aplayer .aplayer-info .aplayer-controller .aplayer-bar-wrap .aplayer-bar .aplayer-played .aplayer-thumb{height:12px;width:12px;right:3px;box-shadow:0 0 5px 0 rgba(0,0,0,.18);transition:all .35s}.aplayer .aplayer-info .aplayer-controller .aplayer-volume-wrap .aplayer-volume-bar-wrap .aplayer-volume-bar,.aplayer .aplayer-info .aplayer-controller .aplayer-volume-wrap .aplayer-volume-bar-wrap .aplayer-volume-bar .aplayer-volume{border-radius:10px;width:6px}.aplayer .aplayer-info .aplayer-controller .aplayer-volume-wrap .aplayer-volume-bar-wrap .aplayer-volume-bar{right:10.5px}.aplayer .aplayer-list ol li{border-top:none}.aplayer .aplayer-list ol li.aplayer-list-light{background:#f8f8f8}#aplayer-float{background:rgba(255,255,255,1);margin:0}.ap-hover{left:-66px!important}.ap-hover:hover{left:0!important}#aplayer-float .aplayer-lrc-current{color:orange;font-size:15px;font-weight:700}.aplayer-lrc{pointer-events:none} \ No newline at end of file diff --git a/tpl/content-category.php b/tpl/content-category.php new file mode 100644 index 0000000..ce47af1 --- /dev/null +++ b/tpl/content-category.php @@ -0,0 +1,42 @@ + + +
    +
    +
    +
    + + + + + +
    + +
    +

    +
    + post_date));//the_time('Y-m-d');?> +
    +
    +
    + +
    +
    + +
    +
    + +
    + +
    +
    + +
    diff --git a/tpl/content-image.php b/tpl/content-image.php new file mode 100644 index 0000000..c242aec --- /dev/null +++ b/tpl/content-image.php @@ -0,0 +1,45 @@ + + +
    +
    +
    + +
    + +
    + +
    +

    +
    + + + + post_date));//the_time('Y-m-d');?> +
    +

    post_content))), 0, 150,"...");?>

    +
    +
    + +
    +
    +
    + +
    +
    + 热度 +
    +
    +
    +
    +
    +
    + diff --git a/tpl/content-none.php b/tpl/content-none.php new file mode 100644 index 0000000..81c5e9b --- /dev/null +++ b/tpl/content-none.php @@ -0,0 +1,48 @@ + + +
    + + +
    + + +

    点击这里开始.', 'akina' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( admin_url( 'post-new.php' ) ) ); ?>

    + + +
    +

    +
    +
      + get_results("SELECT ID,post_title FROM $wpdb->posts where post_status='publish' and post_type='post' ORDER BY ID DESC LIMIT 0 , 20"); + foreach ($result as $post) { + setup_postdata($post); + $postid = $post->ID; + $title = $post->post_title; + ?> +
    • + +
    +
    +
    + + + +

    + +
    +
    diff --git a/tpl/content-page.php b/tpl/content-page.php new file mode 100644 index 0000000..e63ba32 --- /dev/null +++ b/tpl/content-page.php @@ -0,0 +1,42 @@ + + +
    > + +
    + ', '' ); ?> +
    + +
    + '', + ) ); + ?> +
    + +
    + "', '"', false ) + ), + '', + '' + ); + ?> +
    +
    diff --git a/tpl/content-search.php b/tpl/content-search.php new file mode 100644 index 0000000..dbd618b --- /dev/null +++ b/tpl/content-search.php @@ -0,0 +1,30 @@ + + + diff --git a/tpl/content-single.php b/tpl/content-single.php new file mode 100644 index 0000000..5407c9c --- /dev/null +++ b/tpl/content-single.php @@ -0,0 +1,42 @@ + + + diff --git a/tpl/content-status.php b/tpl/content-status.php new file mode 100644 index 0000000..8efbd03 --- /dev/null +++ b/tpl/content-status.php @@ -0,0 +1,41 @@ + + +
    +
    +
    + + <?php the_author(); ?> + +
    +
    +

    post_content))), 0, 150,"...");?>

    +
    + + + + post_date));//the_time('Y-m-d');?> +
    +
    +
    +
    +
    + +
    +
    + 热度 +
    +
    +
    +
    +
    +
    + diff --git a/tpl/content-thumb.php b/tpl/content-thumb.php new file mode 100644 index 0000000..8cfdad9 --- /dev/null +++ b/tpl/content-thumb.php @@ -0,0 +1,56 @@ +ID), 'large'); + $post_img = $large_image_url[0]; + //$post_img = str_replace("//cdn.2heng.xin","//2heng.xin",$post_img); //强制使用又拍云 +}else{ + $post_img = get_bloginfo('template_url') . '/images/temp.png'; +} +$the_cat = get_the_category(); +// 摘要字数限制 + +//add_filter( 'excerpt_length', 'custom_excerpt_length', 120 ); +?> +
    +
    + +
    +
    +
    + +

    + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +

    +
    + + + + post_date)); ?> +
    + +
    +
    + +
    +
    +
    + +
    +
    + 热度 +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/tpl/single-image.php b/tpl/single-image.php new file mode 100644 index 0000000..0e8509a --- /dev/null +++ b/tpl/single-image.php @@ -0,0 +1,40 @@ + + +
    > + +
    + +
    +

    +

    post_date)); ?>   次阅读

    +
    +
    +
    + + +
    + + '', + ) ); + ?> +
    + +
    + + +
    +
    diff --git a/user/page-login.php b/user/page-login.php new file mode 100644 index 0000000..e0fdab6 --- /dev/null +++ b/user/page-login.php @@ -0,0 +1,28 @@ + +
    +
    + + + +
    +
    +错误:请输入用户名。
    '; + } elseif ( ! validate_username( $sanitized_user_login ) ) { + $error .= '错误:此用户名包含无效字符,请输入有效的用户名。
    '; + $sanitized_user_login = ''; + } elseif ( username_exists( $sanitized_user_login ) ) { + $error .= '错误:该用户名已被注册。
    '; + } + + // Check the e-mail address + if ( $user_email == '' ) { + $error .= '错误:请填写电子邮件地址。
    '; + } elseif ( ! is_email( $user_email ) ) { + $error .= '错误:电子邮件地址不正确。
    '; + $user_email = ''; + } elseif ( email_exists( $user_email ) ) { + $error .= '错误:该电子邮件地址已经被注册。
    '; + } + + // Check the password + if(strlen($_POST['user_pass']) < 6){ + $error .= '错误:密码长度至少6位。
    '; + }elseif($_POST['user_pass'] != $_POST['user_pass2']){ + $error .= '错误:两次输入的密码不一致。
    '; + } + + // verification + if(akina_option('login_validate') && strlen($_POST['verification']) > 0 ){ + $error .= '错误:请拖动滑块验证身份
    '; + } + + if($error == '') { + $user_id = wp_create_user( $sanitized_user_login, $_POST['user_pass'], $user_email ); + if ( !$user_id ) { + $error .= sprintf( '错误:无法完成注册请求... 请联系管理员
    ', get_option( 'admin_email' ) ); + }else if (!is_user_logged_in()) { + $user = get_userdatabylogin($sanitized_user_login); + $user_id = $user->ID; + // 自动登录 + wp_set_current_user($user_id, $user_login); + wp_set_auth_cookie($user_id); + do_action('wp_login', $user_login); + } + } +} +?> +
    +
    + + +
    +
    +

    New Account

    +
    +
    " method="post"> +

    +

    +

    +

    + +
    +
    +
    + »拖动滑块验证 +
    + +
    + + + '.$error.'

    '; } ?> + +
    +
    + + + + +

    暂未开放注册。

    + +
    +
    + + + + + \ No newline at end of file diff --git a/user/page-timeline.php b/user/page-timeline.php new file mode 100644 index 0000000..53243f3 --- /dev/null +++ b/user/page-timeline.php @@ -0,0 +1,31 @@ + +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    += me.max) { + me.index = me.max - me.labelWidth -2; + //停止 + me.swipestart = false; + //解锁 + me.isOk = true; + } + if (me.index < 0) { + me.index = me.min; + //未解锁 + me.isOk = false; + } + if (me.index+me.labelWidth+2 == me.max && me.max > 0 && me.isOk) { + //解锁默认操作 + $('#label').unbind().next('#labelTip'). + text(me.opts.successLabelTip).css({'color': '#fff'}); + + me.success(); + } + me.updateView(); + }; + + + /** + * 更新视图 + */ + SliderUnlock.prototype.updateView = function () { + var me = this; + + me.sliderBg.css('width', me.index); + me.elm.find("#label").css("left", me.index + "px") + }; + + /** + * 重置slide的起点 + */ + SliderUnlock.prototype.reset = function () { + var me = this; + + startTime = 0; + + me.index = 0; + me.sliderBg .animate({'width':0},me.opts.duration); + me.elm.find("#label").animate({left: me.index}, me.opts.duration) + .next("#lableTip").animate({opacity: 1}, me.opts.duration); + me.updateView(); + }; + + /** + * 检测元素是否存在 + * @param elm + * @returns {boolean} + */ + SliderUnlock.prototype.checkElm = function (elm) { + if($(elm).length > 0){ + return true; + }else{ + throw "this element does not exist."; + } + }; + + /** + * 检测传入参数是否是function + * @param fn + * @returns {boolean} + */ + SliderUnlock.prototype.checkFn = function (fn) { + if(typeof fn === "function"){ + return true; + }else{ + throw "the param is not a function."; + } + }; + + + window['SliderUnlock'] = SliderUnlock; +})(jQuery, window, document); \ No newline at end of file