PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/184.168.182.1/wp-content/plugins/jetpack/modules/theme-tools.php

https://gitlab.com/endomorphosis/falkenstein
PHP | 119 lines | 53 code | 17 blank | 49 comment | 15 complexity | d4ca3a81088e05fbb68657c48f4116e9 MD5 | raw file
  1. <?php
  2. /*
  3. * Load code specific to themes or theme tools
  4. * This file is special, and is not an actual `module` as such.
  5. * It is included by ./module-extras.php
  6. */
  7. function jetpack_load_theme_tools() {
  8. if ( current_theme_supports( 'social-links' ) ) {
  9. require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/social-links.php' );
  10. }
  11. if ( current_theme_supports( 'tonesque' ) ) {
  12. jetpack_require_lib( 'tonesque' );
  13. }
  14. require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/random-redirect.php' );
  15. }
  16. add_action( 'init', 'jetpack_load_theme_tools', 30 );
  17. // Featured Content has an internal check for theme support in the constructor.
  18. // This could already be defined by Twenty Fourteen if it's loaded first.
  19. // Be sure to not load this on the plugin page in case another plugin is activating
  20. // with the same class name in an attempt to override Jetpack's Featured_Content
  21. if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
  22. require_once( JETPACK__PLUGIN_DIR . 'modules/theme-tools/featured-content.php' );
  23. }
  24. /**
  25. * INFINITE SCROLL
  26. */
  27. /**
  28. * Load theme's infinite scroll annotation file, if present in the IS plugin.
  29. * The `setup_theme` action is used because the annotation files should be using `after_setup_theme` to register support for IS.
  30. *
  31. * As released in Jetpack 2.0, a child theme's parent wasn't checked for in the plugin's bundled support, hence the convoluted way the parent is checked for now.
  32. *
  33. * @uses is_admin, wp_get_theme, get_theme, get_current_theme, apply_filters
  34. * @action setup_theme
  35. * @return null
  36. */
  37. function jetpack_load_infinite_scroll_annotation() {
  38. if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
  39. $theme = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_theme( get_current_theme() );
  40. if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) )
  41. return;
  42. $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
  43. if ( is_readable( $customization_file ) ) {
  44. require_once( $customization_file );
  45. }
  46. elseif ( ! empty( $theme['Template'] ) ) {
  47. $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
  48. if ( is_readable( $customization_file ) )
  49. require_once( $customization_file );
  50. }
  51. }
  52. }
  53. add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
  54. /**
  55. * Prevent IS from being activated if theme doesn't support it
  56. *
  57. * @param bool $can_activate
  58. * @filter jetpack_can_activate_infinite-scroll
  59. * @return bool
  60. */
  61. function jetpack_can_activate_infinite_scroll( $can_activate ) {
  62. return (bool) current_theme_supports( 'infinite-scroll' );
  63. }
  64. add_filter( 'jetpack_can_activate_infinite-scroll', 'jetpack_can_activate_infinite_scroll' );
  65. // Custom Post Types - we don't want a module card for these (yet)
  66. require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/comics.php' );
  67. require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/testimonial.php' );
  68. require_once( JETPACK__PLUGIN_DIR . 'modules/custom-post-types/nova.php' );
  69. /**
  70. * Load theme compat file if it exists.
  71. *
  72. * A theme could add its own compat files here if they like. For example:
  73. *
  74. * add_filter( 'jetpack_theme_compat_files', 'mytheme_jetpack_compat_file' );
  75. * function mytheme_jetpack_compat_file( $files ) {
  76. * $files['mytheme'] = locate_template( 'jetpack-compat.php' );
  77. * return $files;
  78. * }
  79. */
  80. function jetpack_load_theme_compat() {
  81. $compat_files = apply_filters( 'jetpack_theme_compat_files', array(
  82. 'twentyfourteen' => JETPACK__PLUGIN_DIR . 'modules/theme-tools/compat/twentyfourteen.php',
  83. ) );
  84. _jetpack_require_compat_file( get_stylesheet(), $compat_files );
  85. if ( is_child_theme() ) {
  86. _jetpack_require_compat_file( get_template(), $compat_files );
  87. }
  88. }
  89. add_action( 'after_setup_theme', 'jetpack_load_theme_compat', -1 );
  90. /**
  91. * Requires a file once, if the passed key exists in the files array.
  92. *
  93. * @access private
  94. * @param string $key
  95. * @param array $files
  96. * @return void
  97. */
  98. function _jetpack_require_compat_file( $key, $files ) {
  99. if ( array_key_exists( $key, $files ) && is_readable( $files[ $key ] ) ) {
  100. require_once $files[ $key ];
  101. }
  102. }