Guest User

Untitled

a guest
Jul 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. $active_type="home";
  2. $wp_customize->add_setting($active_type.'_categories_max',array(
  3. 'default' => '10',
  4. 'transport' => 'refresh'
  5. ));
  6.  
  7. $wp_customize->add_control( $active_type.'_categories_max',array(
  8. 'type' => 'select',
  9. 'label' => 'Max Items',
  10. 'section' => $active_type.'_categories_section',
  11. 'choices' => array(
  12. '5' => '2',
  13. '10' => '10',
  14. '15' => '15',
  15. '20' => '20',
  16. ),
  17. ));
  18.  
  19. $test = get_theme_mod('home_categories_max');
  20. echo $test;
  21.  
  22. {
  23. "2016-Foundation6-v0.6::single_categories_location_priority": {
  24. "value": "0",
  25. "type": "theme_mod",
  26. "user_id": 1
  27. }
  28. }
  29.  
  30. {"success":true,"data":{"setting_validities":{"single_carousel_location":true},"changeset_status":"publish"
  31. ,"next_changeset_uuid":"9aff0388-b0bc-4be8-ba1a-2fd3cf24772c"}}
  32.  
  33. {"success":false,"data":{"message":"","code":"changeset_already_published","data":null}}
  34.  
  35. File: /wp-includes/theme.php
  36. 889: function set_theme_mod( $name, $value ) {
  37. 890: $mods = get_theme_mods();
  38. 891: $old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
  39. 892:
  40. 893: /**
  41. 894: * Filters the theme mod value on save.
  42. 895: *
  43. 896: * The dynamic portion of the hook name, `$name`, refers to the key name of
  44. 897: * the modification array. For example, 'header_textcolor', 'header_image',
  45. 898: * and so on depending on the theme options.
  46. 899: *
  47. 900: * @since 3.9.0
  48. 901: *
  49. 902: * @param string $value The new value of the theme mod.
  50. 903: * @param string $old_value The current value of the theme mod.
  51. 904: */
  52. 905: $mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
  53. 906:
  54. 907: $theme = get_option( 'stylesheet' );
  55. 908: update_option( "theme_mods_$theme", $mods );
  56. 909: }
  57.  
  58. function _20161230_customize_register( $wp_customize ) {
  59.  
  60. $active_type="home";
  61.  
  62. $wp_customize->add_section( $active_type. 'just_listed' , array(
  63. 'title' => __( 'Just Listed Settings', 'microformata' ),
  64. 'priority' => 53,
  65. ) );
  66.  
  67. $wp_customize->add_setting($active_type.'_categories_max',array(
  68. 'default' => '10',
  69. 'transport' => 'refresh'
  70. ));
  71.  
  72. $wp_customize->add_control( $active_type.'_categories_max',array(
  73. 'type' => 'select',
  74. 'label' => 'Max Items',
  75. 'section' => $active_type.'just_listed',
  76. 'choices' => array(
  77. '5' => '2',
  78. '10' => '10',
  79. '15' => '15',
  80. '20' => '20',
  81. ),
  82. ));
  83. }
  84.  
  85. add_action( 'customize_register', '_20161230_customize_register' );
  86.  
  87. {success: true, data: {setting_validities: {home_categories_max: true}, changeset_status: "publish",…}}
  88. data
  89. :
  90. {setting_validities: {home_categories_max: true}, changeset_status: "publish",…}
  91. changeset_status
  92. :
  93. "publish"
  94. next_changeset_uuid
  95. :
  96. "4b1ac702-3ae2-422d-875a-a02b6f5b2d65"
  97. setting_validities
  98. :
  99. {home_categories_max: true}
  100. success
  101. :
  102. true
Add Comment
Please, Sign In to add comment