assets.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. /**
  3. * JavaScript and CSS files.
  4. *
  5. * @package Pen
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. if ( ! function_exists( 'pen_assets' ) ) {
  11. /**
  12. * Enqueue scripts and styles.
  13. */
  14. function pen_assets() {
  15. $theme_directory = "//cdn.yoqi.me/blog/wp-content/themes/pen";
  16. $css_files = array(
  17. 'normalize' => '/assets/css/normalize.css',
  18. 'animate' => '/assets/css/plugins/animate.css',
  19. 'slicknav' => '/assets/css/plugins/jquery.slicknav.css',
  20. 'base' => '/assets/css/pen-base.css',
  21. 'fonts' => '/assets/css/pen-fonts.css',
  22. 'typography' => '/assets/css/pen-typography.css',
  23. 'layout' => '/assets/css/pen-layout.css',
  24. 'buttons' => '/assets/css/pen-buttons.css',
  25. 'bottom' => '/assets/css/pen-bottom.css',
  26. 'comments' => '/assets/css/pen-comments.css',
  27. 'footer' => '/assets/css/pen-footer.css',
  28. 'header' => '/assets/css/pen-header.css',
  29. 'menus' => '/assets/css/pen-menus.css',
  30. 'navigation' => '/assets/css/pen-navigation.css',
  31. 'forms' => '/assets/css/pen-forms.css',
  32. 'content' => '/assets/css/pen-content.css',
  33. 'thumbnails' => '/assets/css/pen-thumbnails.css',
  34. 'author' => '/assets/css/pen-author.css',
  35. 'pagination' => '/assets/css/pen-pagination.css',
  36. 'share' => '/assets/css/pen-share.css',
  37. 'search-bar' => '/assets/css/pen-search-bar.css',
  38. 'top' => '/assets/css/pen-top.css',
  39. 'widgets' => '/assets/css/pen-widgets.css',
  40. );
  41. // The key has to be the same as the slug in the inline CSS of the customize.php file.
  42. $css_files['css'] = '/assets/css/pen-general.css';
  43. if ( file_exists( $theme_directory . '/assets/css/custom.css' ) ) {
  44. $css_files['custom'] = '/assets/css/custom.css';
  45. }
  46. // foreach ( $css_files as $key => $value ) {
  47. // wp_enqueue_style( 'pen-' . $key, $theme_directory . $value, array(), PEN_THEME_VERSION );
  48. // }
  49. wp_enqueue_style( 'pen-css', $theme_directory . "/dist/css/pan-4af3e60461.min.css", array(), PEN_THEME_VERSION );
  50. //wp_enqueue_script( 'jquery-fittext', $theme_directory . '/assets/js/plugins/jquery.fittext.js', array( 'jquery' ), '1.2', true );
  51. //wp_enqueue_script( 'autosize', $theme_directory . '/assets/js/plugins/autosize.js', array(), '4.0', true );
  52. //wp_enqueue_script( 'respond', $theme_directory . '/assets/js/plugins/respond.js', array( 'jquery' ), '1.4.2', true );
  53. //wp_enqueue_script( 'pen-skip', $theme_directory . '/assets/js/skip-link-focus-fix.js', array( 'jquery' ), PEN_THEME_VERSION, true );
  54. wp_enqueue_script( 'pen-js', $theme_directory . '/dist/js/pan-3480f10a61.min.js', array(), '3.7.3', false );
  55. if ( is_singular() ) {
  56. wp_enqueue_script( 'comment-reply' );
  57. }
  58. ob_start( 'pen_compress_html' );
  59. get_template_part( 'partials/site', 'navigation' );
  60. $navigation_easing = array();
  61. $navigation = ob_get_clean();
  62. if ( $navigation ) {
  63. wp_enqueue_script( 'hoverIntent' );
  64. wp_enqueue_script( 'jquery-superfish', $theme_directory . '/assets/js/plugins/jquery.superfish.js', array( 'jquery' ), '1.7.9', true );
  65. wp_enqueue_script( 'jquery-slicknav', $theme_directory . '/assets/js/plugins/jquery.slicknav.js', array( 'jquery' ), '1.0.10', true );
  66. $easing = pen_option_get( 'navigation_easing' );
  67. if ( $easing ) {
  68. wp_enqueue_script( 'jquery-easing', $theme_directory . '/assets/js/plugins/jquery.easing.js', array( 'jquery' ), '1.3', true );
  69. $navigation_easing = array(
  70. 'height' => array( 'show', $easing ),
  71. );
  72. }
  73. }
  74. wp_enqueue_script( 'jquery-waypoints', $theme_directory . '/assets/js/plugins/jquery.waypoints.js', array( 'jquery' ), '4.0.1', true );
  75. $content_list_type = pen_list_type();
  76. if ( 'masonry' === $content_list_type ) {
  77. wp_enqueue_script( 'imagesloaded' );
  78. wp_enqueue_script( 'masonry' );
  79. }
  80. wp_enqueue_script( 'pen-modernizr', $theme_directory . '/assets/js/plugins/modernizr.js', array(), '3.6', true );
  81. $site_background_effect = pen_option_get( 'color_site_background_effect' );
  82. $trianglify = false;
  83. $trianglify_colors = false;
  84. if ( 'trianglify' === $site_background_effect ) {
  85. $trianglify = true;
  86. /**
  87. * Dear WP.org reviewer,
  88. * Base64 is required to generate a DataURI for a SVG background.
  89. * We can remove this feature entirely if you don't like it?
  90. */
  91. wp_enqueue_script( 'base64', $theme_directory . '/assets/js/plugins/base64.js', array( 'jquery' ), PEN_THEME_VERSION, true );
  92. $trianglify_colors = array(
  93. pen_option_get( 'color_site_background' ),
  94. pen_option_get( 'color_button_background_primary' ),
  95. pen_option_get( 'color_button_background_secondary' ),
  96. pen_option_get( 'color_header_background_primary' ),
  97. pen_option_get( 'color_header_background_secondary' ),
  98. pen_option_get( 'color_navigation_background_primary' ),
  99. pen_option_get( 'color_navigation_background_secondary' ),
  100. );
  101. wp_enqueue_script( 'trianglify', $theme_directory . '/assets/js/plugins/trianglify.js', array( 'jquery', 'base64' ), '2.0.0', true );
  102. }
  103. $shards = false;
  104. $shards_colors = false;
  105. if ( 'shards' === $site_background_effect ) {
  106. $shards = true;
  107. $site_background = new \Pen\Color( pen_option_get( 'color_site_background' ) );
  108. $site_background = array_values( $site_background->getRgb() );
  109. $site_background[] = 0.25;
  110. $header_background_primary = new \Pen\Color( pen_option_get( 'color_header_background_primary' ) );
  111. $header_background_primary = array_values( $header_background_primary->getRgb() );
  112. $header_background_primary[] = 0.25;
  113. $shards_colors = array(
  114. $site_background,
  115. $header_background_primary,
  116. );
  117. wp_enqueue_script( 'shards', $theme_directory . '/assets/js/plugins/shards.js', array( 'jquery' ), '1.1', true );
  118. }
  119. wp_enqueue_script(
  120. 'pen-js',
  121. $theme_directory . '/assets/js/pen-scripts.js',
  122. array_filter(
  123. array(
  124. 'jquery',
  125. 'jquery-masonry',
  126. $shards ? 'shards' : '',
  127. $trianglify ? 'trianglify' : '',
  128. )
  129. ),
  130. PEN_THEME_VERSION,
  131. true
  132. );
  133. wp_localize_script(
  134. 'pen-js',
  135. 'pen_js',
  136. array(
  137. 'header_sticky' => pen_option_get( 'header_sticky' ),
  138. 'list_type' => $content_list_type,
  139. 'trianglify_colors' => $trianglify_colors,
  140. 'shards_colors' => $shards_colors,
  141. 'navigation_arrows' => pen_option_get( 'navigation_arrows' ) ? true : false,
  142. 'navigation_easing' => $navigation_easing,
  143. 'navigation_mobile' => pen_option_get( 'navigation_mobile_display' ) ? true : false,
  144. 'animation_comments' => pen_option_get( 'comments_animation_reveal' ),
  145. 'animation_navigation_speed' => pen_option_get( 'navigation_animation_speed' ),
  146. 'animation_list' => pen_option_get( 'list_animation_reveal' ),
  147. 'animation_list_thumbnails' => pen_option_get( 'list_thumbnail_animation_reveal' ),
  148. 'animation_content' => pen_option_get( 'content_animation_reveal' ),
  149. 'animation_content_thumbnails' => pen_option_get( 'content_thumbnail_animation_reveal' ),
  150. /* phpcs:disable */
  151. 'font_resize' => array(
  152. 'site_title' => pen_option_get( 'font_resize_sitetitle' ),
  153. ),
  154. 'text' => array(
  155. 'pen_theme' => __( 'Pen', 'pen' ),
  156. 'loading' => __( 'Loading...', 'pen' ),
  157. 'enter_keyword' => __( 'Please enter some keywords.', 'pen' ),
  158. 'close' => __( 'Close', 'pen' ),
  159. 'menu' => __( 'Menu', 'pen' ),
  160. 'overview_options_post' => __( 'Content settings overview', 'pen' ),
  161. 'expand_collapse' => __( 'Expand\Collapse', 'pen' ),
  162. 'theme_specific' => __( "This is a part of the 'Pen' theme, so if you switch to another theme this nice little editing tool will be no longer available.", 'pen' ),
  163. ),
  164. /* phpcs:enable */
  165. )
  166. );
  167. if ( file_exists( $theme_directory . '/assets/js/custom.js' ) ) {
  168. wp_enqueue_script( 'pen-custom', $theme_directory . '/assets/js/custom.js', array( 'jquery' ), PEN_THEME_VERSION, true );
  169. }
  170. wp_enqueue_script( 'html5shiv', $theme_directory . '/assets/js/plugins/html5.js', array(), '3.7.3', false );
  171. wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
  172. }
  173. add_action( 'wp_enqueue_scripts', 'pen_assets' );
  174. }