Advertisement
Guest User

Untitled

a guest
Aug 13th, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. // WP THEME CUSTOMIZER: START
  2.  
  3. //// REMOVE SECTIONS
  4. //// TITLE & TAGLINE
  5.  
  6. add_action( 'customize_register', 'wpse8170_customize_register' );
  7. function wpse8170_customize_register( WP_Customize_Manager $wp_customize ) {
  8. $wp_customize->remove_section( 'title_tagline' );
  9. }
  10.  
  11. //// SECTION: LOGO
  12. function wptuts_theme_customizer( $wp_customize ) {
  13.  
  14. /* Section: Pagination */
  15. $wp_customize->add_section( 'themeslug_pagination', array(
  16. 'title' => __( 'Pagination', 'themeslug' ),
  17. ) );
  18. $wp_customize->add_setting( 'pagination_style', array(
  19. 'default' => 'next-previous-links',
  20. ) );
  21. $wp_customize->add_control( 'pagination_style', array(
  22. 'label' => __( 'Pagination Style', 'themeslug' ),
  23. 'section' => 'themeslug_pagination',
  24. 'type' => 'radio',
  25. 'choices' => array(
  26. 'next-previous-links' => __( 'Next/Previous Links', 'themeslug' ),
  27. 'numbered' => __( 'Numbered', 'themeslug' ),
  28. ),
  29. ) );
  30.  
  31. $wp_customize->add_section( 'themeslug_logo_section' , array(
  32. 'title' => __( 'Logo', 'themeslug' ),
  33. 'priority' => 2,
  34. 'description' => 'Upload a logo to replace the default site name and description in the header',
  35. ) );
  36. $wp_customize->add_setting( 'themeslug_logo' );
  37. $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
  38. 'label' => __( 'Logo', 'themeslug' ),
  39. 'section' => 'themeslug_logo_section',
  40. 'settings' => 'themeslug_logo',
  41. ) ) );
  42.  
  43. //// SECTION: Sidebar
  44. $wp_customize->add_setting('sidebar_position', array());
  45. $wp_customize->add_control('sidebar_position', array(
  46. 'label' => __('Sidebar position', 'Ari'),
  47. 'section' => 'layout',
  48. 'settings' => 'sidebar_position',
  49. 'type' => 'radio',
  50. 'choices' => array(
  51. 'left' => 'left',
  52. 'right' => 'right',
  53. ),
  54. ));
  55. $wp_customize->add_section('layout' , array(
  56. 'title' => __('Layout','Ari'),
  57. ));
  58.  
  59. // WP THEME CUSTOMIZER: COLORS
  60. $colors = array();
  61. $colors[] = array(
  62. 'slug'=>'primary_color',
  63. 'default' => '#88C34B',
  64. 'label' => __('Primary Color', 'Ari')
  65. );
  66. $colors[] = array(
  67. 'slug'=>'secondary_color',
  68. 'default' => '#333333',
  69. 'label' => __('Content Text Color', 'Ari')
  70. );
  71. $colors[] = array(
  72. 'slug'=>'headings_color',
  73. 'default' => '#333333',
  74. 'label' => __('Headings Color', 'Ari')
  75. );
  76. $colors[] = array(
  77. 'slug'=>'background_color',
  78. 'default' => '#FFFFFF',
  79. 'label' => __('Background Color', 'Ari')
  80. );
  81. foreach( $colors as $color ) {
  82. // SETTINGS
  83. $wp_customize->add_setting(
  84. $color['slug'], array(
  85. 'default' => $color['default'],
  86. 'type' => 'option',
  87. 'capability' =>
  88. 'edit_theme_options'
  89. )
  90. );
  91.  
  92. // CONTROLS
  93. $wp_customize->add_control(
  94. new WP_Customize_Color_Control(
  95. $wp_customize,
  96. $color['slug'],
  97. array('label' => $color['label'],
  98. 'section' => 'colors',
  99. 'settings' => $color['slug'])
  100. )
  101. );
  102. }
  103.  
  104. // WP THEME CUSTOMIZER: LAST LINE
  105. }
  106. add_action( 'customize_register', 'wptuts_theme_customizer', 11 );
  107. // Posts per page
  108. add_filter('parse_query', 'wpq_parse_query');
  109. function wpq_parse_query($query)
  110. {
  111. if(!$query->is_main_query())
  112. {
  113. return $query;
  114. }
  115. if($query->is_archive())
  116. {
  117. $query->query_vars['posts_per_page'] = get_option('to_count_archives', 1);
  118. }
  119. if($query->is_home())
  120. {
  121. $query->query_vars['posts_per_page'] = get_option('to_count_home', 1);
  122. }
  123. if($query->is_search())
  124. {
  125. $query->query_vars['posts_per_page'] = get_option('to_count_search', 1);
  126. }
  127. return $query;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement