shababshihan

ওয়ার্ডপ্রেস ড্যাশবোর্ড অপশনট্রি ও থি্মঅপশন যুক্ত করবো কিভাবে

Nov 24th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. ওয়ার্ডপ্রেস ড্যাশবোর্ড অপশনট্রি ও থি্মঅপশন যুক্ত করবো কিভাবেঃ
  2.  
  3. ধাপ-১ঃ
  4. https://github.com/valendesigns/option-tree গিঁটহাপের এই লিঙ্ক থেকে অপশনট্রির ডাউনলোড জিপ ফোল্ডার টি ডাউনলোড করি। ফোল্ডার টি আনজিপ করি। ফোল্ডার টির ফুল্লনাম অপশনট্রি মাস্টার আসবে। অপশনট্রি মাস্টার ফোল্ডার টি এডিট করে মাস্টার শব্দ টি বাদ দেই। অপশনট্রি ফোল্ডার টি লোকাল হোষ্ট এর www ডিরেকটরী এর মধ্যে আমার ওয়রকিং ফাইল এর মধ্যে রাখি।(যেহেতু আমি লোকাল হোষ্ট এর মধ্যে কাজ করছি)। আমার মুল ওয়রকিং ফাইলে একটি ফোল্ডার তৈরি করি নাম দেই inc . এখন inc ফোল্ডার এর মধ্যে meta-boxes.php এবং theme-options.php নামক ফাইল দুটি অপশনট্রি ফোল্ডার থেকে কপি করে আনে রাখি। এখন functions.php ফাইল এর মধ্যে
  5. add_filter( 'ot_theme_mode', '__return_true' );
  6. require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );
  7. require( trailingslashit( get_template_directory() ) . 'inc/theme-options.php' ); এই কোড গুলো লিখে অপশনট্রি ও থিম অপশন কে অ্যাক্টিভ করি।
  8.  
  9. এখন ওয়ার্ডপ্রেস ড্যাশবোর্ডে লক্ষ্য করলে দেখা যাবে দুটি নতুন অপশন সংযুক্ত হয়েছে। একটি থিম অপশন অন্যটি অপশনট্রি।
  10.  
  11. ধাপ-২ঃ
  12. এখন লোগো ও সোস্যাল আইকন কিভাবে ডায়নামিক করব তা জানবোঃ
  13. প্রথমে index.php ফাইলে গিয়ে লোগো যে ডিভে আছে সেখানে নিম্নোক্ত কোড টি লিখিঃ"<?php get_option_tree( 'upload_logo', '', true ); ?>" এবং
  14. সোস্যাল আইকন যে ডিভে আছে সেখানে নিম্নোক্ত কোড টি লিখিঃ "<?php get_option_tree( 'facebook_link', '', true ); ?>" data-toggle="tooltip" title="click on facebook"
  15. theme-options.php ফাইল এর লোগো ও সোস্যাল আইকন ডায়নামিক করার জন্য নিম্নক্ত কোড গুলো লিখিঃ এই কোড গুলো লিখার পর ওয়ার্ডপ্রেস ড্যাশবোর্ডে লক্ষ্য করলে দেখা যাবে যেঃ আপ্পেরাঞ্চে গিয়ে থিম অপশন এর মধ্যে লোগো ও সোস্যাল আইকন ডায়নামিক করি।
  16.  
  17. <?php
  18. /**
  19. * Initialize the options before anything else.
  20. */
  21. add_action( 'admin_init', '_custom_theme_options', 1 );
  22.  
  23. function _custom_theme_options() {
  24.  
  25. $saved_settings = get_option( 'option_tree_settings', array() );
  26.  
  27. $custom_settings = array(
  28. 'contextual_help' => array(
  29. 'content' => array(
  30. array(
  31. 'id' => 'general_help',
  32. 'title' => 'General',
  33. 'content' => '<p>Help content goes here!</p>'
  34. )
  35. ),
  36. 'sidebar' => '<p>Sidebar content goes here!</p>'
  37. ),
  38. 'sections' => array(
  39. array(
  40. 'title' => 'Home Page',
  41. 'id' => 'home'
  42. ),
  43. array(
  44. 'title' => 'social area',
  45. 'id' => 'social_css'
  46. )
  47. ),
  48. 'settings' => array(
  49. array(
  50. 'label' => 'Upload Your white Logo',
  51. 'id' => 'upload_logo',
  52. 'type' => 'upload',
  53.  
  54. 'section' => 'home'
  55. ),
  56. array(
  57. 'label' => 'Upload Your Dark Logo',
  58. 'id' => 'upload_dareklogo',
  59. 'type' => 'upload',
  60.  
  61. 'section' => 'home'
  62. ),
  63.  
  64. array(
  65. 'label' => 'put your facebook link hear',
  66. 'id' => 'facebook_link',
  67. 'type' => 'text',
  68. 'std' => 'http://',
  69. 'section' => 'social_css'
  70. ),
  71. array(
  72. 'label' => 'put your facebook description here',
  73. 'id' => 'facebook_description',
  74. 'type' => 'textarea_simple',
  75. 'std' => 'description',
  76. 'section' => 'social_css'
  77. ),
  78. array(
  79. 'label' => 'put your twitter link hear',
  80. 'id' => 'twitter_link',
  81. 'type' => 'text',
  82. 'std' => 'http://',
  83. 'section' => 'social_css'
  84. ),
  85. array(
  86. 'label' => 'put your twitter description here',
  87. 'id' => 'twitter_description',
  88. 'type' => 'textarea_simple',
  89. 'std' => 'description',
  90. 'section' => 'social_css'
  91. ),
  92.  
  93. array(
  94. 'label' => 'put your google-plus link hear',
  95. 'id' => 'google-plus_link',
  96. 'type' => 'text',
  97. 'std' => 'http://',
  98. 'section' => 'social_css'
  99. ),
  100. array(
  101. 'label' => 'put your google-plus description here',
  102. 'id' => 'google-plus_description',
  103. 'type' => 'textarea_simple',
  104. 'std' => 'description',
  105. 'section' => 'social_css'
  106. ),
  107.  
  108. array(
  109. 'label' => 'put your linkedin link hear',
  110. 'id' => 'linkedin_link',
  111. 'type' => 'text',
  112. 'std' => 'http://',
  113. 'section' => 'social_css'
  114. ),
  115. array(
  116. 'label' => 'put your linkedin description here',
  117. 'id' => 'linkedin_description',
  118. 'type' => 'textarea_simple',
  119. 'std' => 'description',
  120. 'section' => 'social_css'
  121. ),
  122. array(
  123. 'label' => 'put your pinterest link hear',
  124. 'id' => 'pinterest_link',
  125. 'type' => 'text',
  126. 'std' => 'http://',
  127. 'section' => 'social_css'
  128. ),
  129. array(
  130. 'label' => 'put your pinterest description here',
  131. 'id' => 'pinterest_description',
  132. 'type' => 'textarea_simple',
  133. 'std' => 'description',
  134. 'section' => 'social_css'
  135. ),
  136. )
  137. );
  138.  
  139. /* allow settings to be filtered before saving */
  140. $custom_settings = apply_filters( 'option_tree_settings_args', $custom_settings );
  141.  
  142. /* settings are not the same update the DB */
  143. if ( $saved_settings !== $custom_settings ) {
  144. update_option( 'option_tree_settings', $custom_settings );
  145. }
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment