PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/functions.php

https://gitlab.com/zamuro57/project-ar2
PHP | 151 lines | 96 code | 29 blank | 26 comment | 3 complexity | c058a0c1be33af4143b6d314a57f96cc MD5 | raw file
  1. <?php
  2. define ( 'AR2_CHILD', is_child_theme() );
  3. define ( 'AR2_VERSION' , wp_get_theme()->get( 'Version' ) );
  4. define ( 'AR2_LIB', get_template_directory() . '/library' );
  5. // Set this to true if you wish to use custom stylesheets.
  6. // CSS files have to be placed in /css/styles/ folder.
  7. define( 'AR2_ALLOW_CUSTOM_STYLES', false );
  8. do_action( 'ar2_init' );
  9. /**
  10. * Theme setup function - to be run during 'after_setup_theme' action hook.
  11. * @since 1.6
  12. */
  13. add_action( 'after_setup_theme', 'ar2_setup', 10 );
  14. if ( !function_exists('ar2_setup') ) :
  15. function ar2_setup() {
  16. /* Load theme options */
  17. require_once AR2_LIB . '/options.php';
  18. /* Post Views API */
  19. require_once AR2_LIB . '/postviews.php';
  20. /* Load theme library files */
  21. require_once AR2_LIB . '/actions.php';
  22. require_once AR2_LIB . '/filters.php';
  23. require_once AR2_LIB . '/template.php';
  24. require_once AR2_LIB . '/thumbnails.php';
  25. require_once AR2_LIB . '/styles.php';
  26. require_once AR2_LIB . '/widgets.php';
  27. //require_once AR2_LIB . '/shortcodes.php';
  28. require_once AR2_LIB . '/admin/form.php';
  29. require_once AR2_LIB . '/admin/admin.php';
  30. /* Langauge support */
  31. load_theme_textdomain( 'ar2', get_template_directory() . '/language' );
  32. $locale = get_locale();
  33. $locale_file = get_template_directory() . "/languages/$locale.php";
  34. if ( is_readable( $locale_file ) )
  35. require_once( $locale_file );
  36. /* Theme support */
  37. add_theme_support( 'post-thumbnails' );
  38. add_theme_support( 'nav-menus' );
  39. add_theme_support( 'automatic-feed-links' );
  40. add_theme_support( 'custom-background', array (
  41. 'default-color' => 'F0F0F0',
  42. 'wp-head-callback' => 'ar2_custom_bg_header_callback',
  43. ) );
  44. add_theme_support( 'custom-header', array (
  45. 'width' => 960,
  46. 'height' => 120,
  47. 'default-text-color' => '333',
  48. 'wp-head-callback' => 'ar2_header_style',
  49. 'admin-head-callback' => 'ar2_admin_header_style',
  50. 'admin-preview-callback' => 'ar2_admin_header_image',
  51. ) );
  52. add_theme_support( 'post-formats', array (
  53. 'gallery',
  54. 'image',
  55. 'video',
  56. 'audio',
  57. ) );
  58. /* Menus locations */
  59. register_nav_menus( array (
  60. 'main-menu' => __( 'Main Menu', 'ar2' ),
  61. 'top-menu' => __( 'Top Menu', 'ar2' ),
  62. 'footer-nav' => __( 'Footer Navigation', 'ar2' )
  63. ));
  64. /* Register sidebars */
  65. ar2_add_sidebars();
  66. add_action( 'wp_footer', 'ar2_add_header_js', 100 );
  67. // Editor Style
  68. add_editor_style();
  69. /* Thumbnail sizes */
  70. ar2_add_theme_thumbnails();
  71. /* Max image size */
  72. $max_image_size = ar2_post_thumbnail_size();
  73. $content_width = $max_image_size[ 0 ];
  74. set_post_thumbnail_size( $max_image_size[ 0 ], $max_image_size[ 1 ] );
  75. // print_r($ar2_options);
  76. }
  77. endif;
  78. /**
  79. * Sidebar setup function.
  80. * @since 1.6
  81. */
  82. function ar2_add_sidebars() {
  83. /* Default sidebars */
  84. register_sidebar( array(
  85. 'name' => __( 'Primary Sidebar', 'ar2' ),
  86. 'id' => 'primary-sidebar',
  87. 'before_widget' => '<aside id="%1$s" class="%2$s widget clearfix">',
  88. 'after_widget' => '</aside>',
  89. 'before_title' => '<h3 class="widget-title">',
  90. 'after_title' => '</h3>'
  91. ) );
  92. register_sidebar( array(
  93. 'name' => __( 'Bottom Content #1', 'ar2' ),
  94. 'id' => 'bottom-content-1',
  95. 'before_widget' => '<aside id="%1$s" class="%2$s widget clearfix">',
  96. 'after_widget' => '</aside>',
  97. 'before_title' => '<h3 class="widget-title">',
  98. 'after_title' => '</h3>'
  99. ) );
  100. register_sidebar( array(
  101. 'name' => __( 'Bottom Content #2', 'ar2' ),
  102. 'id' => 'bottom-content-2',
  103. 'before_widget' => '<aside id="%1$s" class="%2$s widget clearfix">',
  104. 'after_widget' => '</aside>',
  105. 'before_title' => '<h3 class="widget-title">',
  106. 'after_title' => '</h3>'
  107. ) );
  108. /* Footer sidebars (4 sidebars) */
  109. $footer_sidebars = 4;
  110. for( $i = 1; $i < $footer_sidebars + 1; $i++ ) {
  111. register_sidebar( array(
  112. 'name' => sprintf( __( 'Footer Sidebar #%s', 'ar2' ), $i ),
  113. 'id' => 'footer-sidebar-' . $i,
  114. 'before_widget' => '<aside id="%1$s" class="%2$s widget clearfix">',
  115. 'after_widget' => '</aside>',
  116. 'before_title' => '<h3 class="widget-title">',
  117. 'after_title' => '</h3>'
  118. ) );
  119. }
  120. }
  121. /* End of file functions.php */
  122. /* Location: ./functions.php */