kalponikoronno

optiontree

Dec 15th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.37 KB | None | 0 0
  1. step 1:
  2.     download option tree plugin "https://wordpress.org/plugins/option-tree
  3. ========================================================================================================
  4. step 2:
  5.     to add "ot-loader.php" add_filter and require into "functions.php"  
  6.     Add the following code to the beginning of your `functions.php`.
  7.  
  8. `/**
  9.  * Required: set 'ot_theme_mode' filter to true.
  10.  */
  11. add_filter( 'ot_theme_mode', '__return_true' );
  12.  
  13. /**
  14.  * Required: include OptionTree.
  15.  */
  16. require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );`
  17.  
  18.     For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode.
  19.  
  20. ============================================================================================================
  21.  
  22. step 3:
  23.     ->copy "demo-theme-options.php" from ( option-tree>assets>theme-mode )  
  24.     ->put it into "inc" folder,
  25.     ->rename it "theme-options.php" >
  26.     ->then call if from functions.php    include_once('inc/theme-options.php');
  27.  
  28. ========================================================================================================
  29. step 4: edit "theme-options.php" to create your theme option
  30. ========================================================================================================
  31. step 5: after edit import the option to your desirable location
  32.  
  33. example:
  34. here is option tree id = portfolio_text_change
  35.  
  36. <?php
  37.         $portfolio_text_change = ot_get_option('portfolio_text_change');
  38.            
  39.  ?>
  40.  
  41. <?php echo $portfolio_text_change; ?>
  42.  
  43.  
  44. ======================XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==================
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. ===========theme-options.php===========
  53.  
  54. <?php
  55.  
  56. add_action( 'admin_init', 'custom_theme_options' );
  57.  
  58. function custom_theme_options() {
  59.   $saved_settings = get_option( ot_settings_id(), array() );
  60.  
  61.   $custom_settings = array(
  62.      
  63.      /*all codes will be written here*/
  64.      
  65.      
  66.   );
  67.  
  68.  
  69.   $custom_settings = apply_filters( ot_settings_id() . '_args', $custom_settings );
  70.  
  71.   if ( $saved_settings !== $custom_settings ) {
  72.     update_option( ot_settings_id(), $custom_settings );
  73.   }
  74.  
  75.  
  76. }
  77.  
  78.  
  79. ===========contextrual help===========
  80.  
  81. 'contextual_help' => array(
  82.   'content'       => array(
  83.     array(
  84.       'id'        => 'option_types_help',
  85.       'title'     => __( 'Option Types', 'theme-text-domain' ),
  86.       'content'   => '<p>' . __( 'Help content goes here!', 'theme-text-domain' ) . '</p>'
  87.     )
  88.   ),
  89.   'sidebar'       => '<p>' . __( 'Sidebar content goes here!', 'theme-text-domain' ) . '</p>'
  90. ),      
  91.  
  92.  
  93. ===========section===========
  94.  
  95.  
  96. 'sections'        => array(
  97.   array(
  98.     'id'          => 'option_types',
  99.     'title'       => __( 'Option Types', 'theme-text-domain' )
  100.   )
  101. ),
  102.  
  103. ===========settings===========
  104.  
  105.     'settings'        => array(
  106.  
  107. /*here is data*/
  108.  
  109. )
  110.  
  111.  
  112. ===========settings===========
  113.  
  114.     'settings'        => array(
  115.   /*Copy start here*/
  116.       array(
  117.         'id'          => 'demo_background',
  118.         'label'       => __( 'Background', 'theme-text-domain' ),
  119.         'desc'        => sprintf( __( 'The Background option type is for ' ),
  120.         'std'         => '',
  121.         'type'        => 'background',
  122.         'section'     => 'option_types',
  123.         'rows'        => '',
  124.         'post_type'   => '',
  125.         'taxonomy'    => '',
  126.         'min_max_step'=> '',
  127.         'class'       => '',
  128.         'condition'   => '',
  129.         'operator'    => 'and'
  130.       )
  131.   /*Copy end here*/
  132. )
  133.  
  134.  
  135. ==============================
  136.  
  137.  
  138. <!--loop start-->
  139.     <?php
  140.           $socialicons = ot_get_option( 'social_icons', array() );
  141.  
  142.           if ( ! empty( $socialicons ) ) {
  143.             foreach( $socialicons as $socialicon ) {
  144.               echo '
  145.                    <!--code strat-->
  146.  
  147.                          <li><a href="' . $socialicon['social_link_ad'] . '" data-placement="top" title="' . $socialicon['social_title'] . '"><i class="fa fa-' . $socialicon['social_font'] . '"></i></a></li>
  148.  
  149.                    <!--code end-->
  150.  
  151.                ';
  152.             }
  153.           }                        
  154.     ?>
  155. <!--loop end-->
  156.  
  157. ==============================
  158.  
  159. <?php
  160.     $portfolio_text_change = ot_get_option('portfolio_text_change');
  161.        
  162.  ?>
Advertisement
Add Comment
Please, Sign In to add comment