Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.11 KB | None | 0 0
  1. **************************** Monitor.js **************************************
  2.  
  3. JQuery(document).ready( function() {
  4. JQuery("#test").html("<span>This is a test.</span>");
  5. });
  6.  
  7.  
  8. **************************** Functions.php **************************************
  9.  
  10. <?php
  11.  
  12. /*function add_monitor(){
  13. wp_register_script('monitor','/scripts/monitor.js', array('jquery'), null, true);
  14. wp_enqueue_script('monitor');
  15. };
  16.  
  17. add_action('wp_enqueue_scripts', 'add_monitor');
  18. */
  19. /**
  20. * Twenty Fourteen functions and definitions
  21. *
  22. * Set up the theme and provides some helper functions, which are used in the
  23. * theme as custom template tags. Others are attached to action and filter
  24. * hooks in WordPress to change core functionality.
  25. *
  26. * When using a child theme you can override certain functions (those wrapped
  27. * in a function_exists() call) by defining them first in your child theme's
  28. * functions.php file. The child theme's functions.php file is included before
  29. * the parent theme's file, so the child theme functions would be used.
  30. *
  31. * @link http://codex.wordpress.org/Theme_Development
  32. * @link http://codex.wordpress.org/Child_Themes
  33. *
  34. * Functions that are not pluggable (not wrapped in function_exists()) are
  35. * instead attached to a filter or action hook.
  36. *
  37. * For more information on hooks, actions, and filters,
  38. * @link http://codex.wordpress.org/Plugin_API
  39. *
  40. * @package WordPress
  41. * @subpackage Twenty_Fourteen
  42. * @since Twenty Fourteen 1.0
  43. */
  44.  
  45. /**
  46. * Set up the content width value based on the theme's design.
  47. *
  48. * @see twentyfourteen_content_width()
  49. *
  50. * @since Twenty Fourteen 1.0
  51. */
  52. if ( ! isset( $content_width ) ) {
  53. $content_width = 474;
  54. }
  55.  
  56. /**
  57. * Twenty Fourteen only works in WordPress 3.6 or later.
  58. */
  59. if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) {
  60. require get_template_directory() . '/inc/back-compat.php';
  61. }
  62.  
  63. if ( ! function_exists( 'twentyfourteen_setup' ) ) :
  64. /**
  65. * Twenty Fourteen setup.
  66. *
  67. * Set up theme defaults and registers support for various WordPress features.
  68. *
  69. * Note that this function is hooked into the after_setup_theme hook, which
  70. * runs before the init hook. The init hook is too late for some features, such
  71. * as indicating support post thumbnails.
  72. *
  73. * @since Twenty Fourteen 1.0
  74. */
  75. function twentyfourteen_setup() {
  76.  
  77. /*
  78. * Make Twenty Fourteen available for translation.
  79. *
  80. * Translations can be added to the /languages/ directory.
  81. * If you're building a theme based on Twenty Fourteen, use a find and
  82. * replace to change 'twentyfourteen' to the name of your theme in all
  83. * template files.
  84. */
  85. load_theme_textdomain( 'twentyfourteen', get_template_directory() . '/languages' );
  86.  
  87. // This theme styles the visual editor to resemble the theme style.
  88. add_editor_style( array( 'css/editor-style.css', twentyfourteen_font_url(), 'genericons/genericons.css' ) );
  89.  
  90. // Add RSS feed links to <head> for posts and comments.
  91. add_theme_support( 'automatic-feed-links' );
  92.  
  93. // Enable support for Post Thumbnails, and declare two sizes.
  94. add_theme_support( 'post-thumbnails' );
  95. set_post_thumbnail_size( 672, 372, true );
  96. add_image_size( 'twentyfourteen-full-width', 1038, 576, true );
  97.  
  98. // This theme uses wp_nav_menu() in two locations.
  99. register_nav_menus( array(
  100. 'primary' => __( 'Top primary menu', 'twentyfourteen' ),
  101. 'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ),
  102. ) );
  103.  
  104. /*
  105. * Switch default core markup for search form, comment form, and comments
  106. * to output valid HTML5.
  107. */
  108. add_theme_support( 'html5', array(
  109. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
  110. ) );
  111.  
  112. /*
  113. * Enable support for Post Formats.
  114. * See http://codex.wordpress.org/Post_Formats
  115. */
  116. add_theme_support( 'post-formats', array(
  117. 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery',
  118. ) );
  119.  
  120. // This theme allows users to set a custom background.
  121. add_theme_support( 'custom-background', apply_filters( 'twentyfourteen_custom_background_args', array(
  122. 'default-color' => 'f5f5f5',
  123. ) ) );
  124.  
  125. // Add support for featured content.
  126. add_theme_support( 'featured-content', array(
  127. 'featured_content_filter' => 'twentyfourteen_get_featured_posts',
  128. 'max_posts' => 6,
  129. ) );
  130.  
  131. // This theme uses its own gallery styles.
  132. add_filter( 'use_default_gallery_style', '__return_false' );
  133. }
  134. endif; // twentyfourteen_setup
  135. add_action( 'after_setup_theme', 'twentyfourteen_setup' );
  136.  
  137. /**
  138. * Adjust content_width value for image attachment template.
  139. *
  140. * @since Twenty Fourteen 1.0
  141. */
  142. function twentyfourteen_content_width() {
  143. if ( is_attachment() && wp_attachment_is_image() ) {
  144. $GLOBALS['content_width'] = 810;
  145. }
  146. }
  147. add_action( 'template_redirect', 'twentyfourteen_content_width' );
  148.  
  149. /**
  150. * Getter function for Featured Content Plugin.
  151. *
  152. * @since Twenty Fourteen 1.0
  153. *
  154. * @return array An array of WP_Post objects.
  155. */
  156. function twentyfourteen_get_featured_posts() {
  157. /**
  158. * Filter the featured posts to return in Twenty Fourteen.
  159. *
  160. * @since Twenty Fourteen 1.0
  161. *
  162. * @param array|bool $posts Array of featured posts, otherwise false.
  163. */
  164. return apply_filters( 'twentyfourteen_get_featured_posts', array() );
  165. }
  166.  
  167. /**
  168. * A helper conditional function that returns a boolean value.
  169. *
  170. * @since Twenty Fourteen 1.0
  171. *
  172. * @return bool Whether there are featured posts.
  173. */
  174. function twentyfourteen_has_featured_posts() {
  175. return ! is_paged() && (bool) twentyfourteen_get_featured_posts();
  176. }
  177.  
  178. /**
  179. * Register three Twenty Fourteen widget areas.
  180. *
  181. * @since Twenty Fourteen 1.0
  182. */
  183. function twentyfourteen_widgets_init() {
  184. require get_template_directory() . '/inc/widgets.php';
  185. register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
  186.  
  187. register_sidebar( array(
  188. 'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
  189. 'id' => 'sidebar-1',
  190. 'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
  191. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  192. 'after_widget' => '</aside>',
  193. 'before_title' => '<h1 class="widget-title">',
  194. 'after_title' => '</h1>',
  195. ) );
  196. register_sidebar( array(
  197. 'name' => __( 'Content Sidebar', 'twentyfourteen' ),
  198. 'id' => 'sidebar-2',
  199. 'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
  200. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  201. 'after_widget' => '</aside>',
  202. 'before_title' => '<h1 class="widget-title">',
  203. 'after_title' => '</h1>',
  204. ) );
  205. register_sidebar( array(
  206. 'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
  207. 'id' => 'sidebar-3',
  208. 'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
  209. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  210. 'after_widget' => '</aside>',
  211. 'before_title' => '<h1 class="widget-title">',
  212. 'after_title' => '</h1>',
  213. ) );
  214. }
  215. add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
  216.  
  217. /**
  218. * Register Lato Google font for Twenty Fourteen.
  219. *
  220. * @since Twenty Fourteen 1.0
  221. *
  222. * @return string
  223. */
  224. function twentyfourteen_font_url() {
  225. $font_url = '';
  226. /*
  227. * Translators: If there are characters in your language that are not supported
  228. * by Lato, translate this to 'off'. Do not translate into your own language.
  229. */
  230. if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) {
  231. $font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
  232. }
  233.  
  234. return $font_url;
  235. }
  236.  
  237. /**
  238. * Enqueue scripts and styles for the front end.
  239. *
  240. * @since Twenty Fourteen 1.0
  241. */
  242. function twentyfourteen_scripts() {
  243. // Add Lato font, used in the main stylesheet.
  244. wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
  245.  
  246. // Add Genericons font, used in the main stylesheet.
  247. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.3' );
  248.  
  249. // Load our main stylesheet.
  250. wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri(), array( 'genericons' ) );
  251.  
  252. // Load the Internet Explorer specific stylesheet.
  253. wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style', 'genericons' ), '20131205' );
  254. wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
  255.  
  256. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  257. wp_enqueue_script( 'comment-reply' );
  258. }
  259.  
  260. if ( is_singular() && wp_attachment_is_image() ) {
  261. wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
  262. }
  263.  
  264. if ( is_active_sidebar( 'sidebar-3' ) ) {
  265. wp_enqueue_script( 'jquery-masonry' );
  266. }
  267.  
  268. if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
  269. wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true );
  270. wp_localize_script( 'twentyfourteen-slider', 'featuredSliderDefaults', array(
  271. 'prevText' => __( 'Previous', 'twentyfourteen' ),
  272. 'nextText' => __( 'Next', 'twentyfourteen' )
  273. ) );
  274. }
  275.  
  276. wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20140616', true );
  277. }
  278. add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
  279.  
  280. /**
  281. * Enqueue Google fonts style to admin screen for custom header display.
  282. *
  283. * @since Twenty Fourteen 1.0
  284. */
  285. function twentyfourteen_admin_fonts() {
  286. wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
  287. }
  288. add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' );
  289.  
  290. if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
  291. /**
  292. * Print the attached image with a link to the next attached image.
  293. *
  294. * @since Twenty Fourteen 1.0
  295. */
  296. function twentyfourteen_the_attached_image() {
  297. $post = get_post();
  298. /**
  299. * Filter the default Twenty Fourteen attachment size.
  300. *
  301. * @since Twenty Fourteen 1.0
  302. *
  303. * @param array $dimensions {
  304. * An array of height and width dimensions.
  305. *
  306. * @type int $height Height of the image in pixels. Default 810.
  307. * @type int $width Width of the image in pixels. Default 810.
  308. * }
  309. */
  310. $attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 810, 810 ) );
  311. $next_attachment_url = wp_get_attachment_url();
  312.  
  313. /*
  314. * Grab the IDs of all the image attachments in a gallery so we can get the URL
  315. * of the next adjacent image in a gallery, or the first image (if we're
  316. * looking at the last image in a gallery), or, in a gallery of one, just the
  317. * link to that image file.
  318. */
  319. $attachment_ids = get_posts( array(
  320. 'post_parent' => $post->post_parent,
  321. 'fields' => 'ids',
  322. 'numberposts' => -1,
  323. 'post_status' => 'inherit',
  324. 'post_type' => 'attachment',
  325. 'post_mime_type' => 'image',
  326. 'order' => 'ASC',
  327. 'orderby' => 'menu_order ID',
  328. ) );
  329.  
  330. // If there is more than 1 attachment in a gallery...
  331. if ( count( $attachment_ids ) > 1 ) {
  332. foreach ( $attachment_ids as $attachment_id ) {
  333. if ( $attachment_id == $post->ID ) {
  334. $next_id = current( $attachment_ids );
  335. break;
  336. }
  337. }
  338.  
  339. // get the URL of the next image attachment...
  340. if ( $next_id ) {
  341. $next_attachment_url = get_attachment_link( $next_id );
  342. }
  343.  
  344. // or get the URL of the first image attachment.
  345. else {
  346. $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
  347. }
  348. }
  349.  
  350. printf( '<a href="%1$s" rel="attachment">%2$s</a>',
  351. esc_url( $next_attachment_url ),
  352. wp_get_attachment_image( $post->ID, $attachment_size )
  353. );
  354. }
  355. endif;
  356.  
  357. if ( ! function_exists( 'twentyfourteen_list_authors' ) ) :
  358. /**
  359. * Print a list of all site contributors who published at least one post.
  360. *
  361. * @since Twenty Fourteen 1.0
  362. */
  363. function twentyfourteen_list_authors() {
  364. $contributor_ids = get_users( array(
  365. 'fields' => 'ID',
  366. 'orderby' => 'post_count',
  367. 'order' => 'DESC',
  368. 'who' => 'authors',
  369. ) );
  370.  
  371. foreach ( $contributor_ids as $contributor_id ) :
  372. $post_count = count_user_posts( $contributor_id );
  373.  
  374. // Move on if user has not published a post (yet).
  375. if ( ! $post_count ) {
  376. continue;
  377. }
  378. ?>
  379.  
  380. <div class="contributor">
  381. <div class="contributor-info">
  382. <div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
  383. <div class="contributor-summary">
  384. <h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2>
  385. <p class="contributor-bio">
  386. <?php echo get_the_author_meta( 'description', $contributor_id ); ?>
  387. </p>
  388. <a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
  389. <?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?>
  390. </a>
  391. </div><!-- .contributor-summary -->
  392. </div><!-- .contributor-info -->
  393. </div><!-- .contributor -->
  394.  
  395. <?php
  396. endforeach;
  397. }
  398. endif;
  399.  
  400. /**
  401. * Extend the default WordPress body classes.
  402. *
  403. * Adds body classes to denote:
  404. * 1. Single or multiple authors.
  405. * 2. Presence of header image except in Multisite signup and activate pages.
  406. * 3. Index views.
  407. * 4. Full-width content layout.
  408. * 5. Presence of footer widgets.
  409. * 6. Single views.
  410. * 7. Featured content layout.
  411. *
  412. * @since Twenty Fourteen 1.0
  413. *
  414. * @param array $classes A list of existing body class values.
  415. * @return array The filtered body class list.
  416. */
  417. function twentyfourteen_body_classes( $classes ) {
  418. if ( is_multi_author() ) {
  419. $classes[] = 'group-blog';
  420. }
  421.  
  422. if ( get_header_image() ) {
  423. $classes[] = 'header-image';
  424. } elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ) ) ) {
  425. $classes[] = 'masthead-fixed';
  426. }
  427.  
  428. if ( is_archive() || is_search() || is_home() ) {
  429. $classes[] = 'list-view';
  430. }
  431.  
  432. if ( ( ! is_active_sidebar( 'sidebar-2' ) )
  433. || is_page_template( 'page-templates/full-width.php' )
  434. || is_page_template( 'page-templates/contributors.php' )
  435. || is_attachment() ) {
  436. $classes[] = 'full-width';
  437. }
  438.  
  439. if ( is_active_sidebar( 'sidebar-3' ) ) {
  440. $classes[] = 'footer-widgets';
  441. }
  442.  
  443. if ( is_singular() && ! is_front_page() ) {
  444. $classes[] = 'singular';
  445. }
  446.  
  447. if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
  448. $classes[] = 'slider';
  449. } elseif ( is_front_page() ) {
  450. $classes[] = 'grid';
  451. }
  452.  
  453. return $classes;
  454. }
  455. add_filter( 'body_class', 'twentyfourteen_body_classes' );
  456.  
  457. /**
  458. * Extend the default WordPress post classes.
  459. *
  460. * Adds a post class to denote:
  461. * Non-password protected page with a post thumbnail.
  462. *
  463. * @since Twenty Fourteen 1.0
  464. *
  465. * @param array $classes A list of existing post class values.
  466. * @return array The filtered post class list.
  467. */
  468. function twentyfourteen_post_classes( $classes ) {
  469. if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) {
  470. $classes[] = 'has-post-thumbnail';
  471. }
  472.  
  473. return $classes;
  474. }
  475. add_filter( 'post_class', 'twentyfourteen_post_classes' );
  476.  
  477. /**
  478. * Create a nicely formatted and more specific title element text for output
  479. * in head of document, based on current view.
  480. *
  481. * @since Twenty Fourteen 1.0
  482. *
  483. * @global int $paged WordPress archive pagination page count.
  484. * @global int $page WordPress paginated post page count.
  485. *
  486. * @param string $title Default title text for current view.
  487. * @param string $sep Optional separator.
  488. * @return string The filtered title.
  489. */
  490. function twentyfourteen_wp_title( $title, $sep ) {
  491. global $paged, $page;
  492.  
  493. if ( is_feed() ) {
  494. return $title;
  495. }
  496.  
  497. // Add the site name.
  498. $title .= get_bloginfo( 'name', 'display' );
  499.  
  500. // Add the site description for the home/front page.
  501. $site_description = get_bloginfo( 'description', 'display' );
  502. if ( $site_description && ( is_home() || is_front_page() ) ) {
  503. $title = "$title $sep $site_description";
  504. }
  505.  
  506. // Add a page number if necessary.
  507. if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
  508. $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );
  509. }
  510.  
  511. return $title;
  512. }
  513. add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
  514.  
  515. // Implement Custom Header features.
  516. require get_template_directory() . '/inc/custom-header.php';
  517.  
  518. // Custom template tags for this theme.
  519. require get_template_directory() . '/inc/template-tags.php';
  520.  
  521. // Add Theme Customizer functionality.
  522. require get_template_directory() . '/inc/customizer.php';
  523.  
  524. /*
  525. * Add Featured Content functionality.
  526. *
  527. * To overwrite in a plugin, define your own Featured_Content class on or
  528. * before the 'setup_theme' hook.
  529. */
  530. if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
  531. require get_template_directory() . '/inc/featured-content.php';
  532. }
  533.  
  534. function add_monitor(){
  535. wp_enqueue_script('jquery');
  536. wp_enqueue_script('monitor', '/scripts/monitor.js', array('jquery'));
  537. }
  538.  
  539. add_action('wp_enqueue_scripts', 'add_monitor');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement