PageRenderTime 40ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website tin tức thời trang và cuộc sống PHP/code_goclamdep/wp-content/themes/premiumnews/functions/admin-framework-settings.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 306 lines | 280 code | 19 blank | 7 comment | 4 complexity | 2b3959f908c7b9a83c611d063a1d2461 MD5 | raw file
  1. <?php
  2. /*-----------------------------------------------------------------------------------*/
  3. /* Framework Settings page - woothemes_framework_settings_page */
  4. /*-----------------------------------------------------------------------------------*/
  5. function woothemes_framework_settings_page(){
  6. $themename = get_option( 'woo_themename' );
  7. $manualurl = get_option( 'woo_manual' );
  8. $shortname = 'framework_woo';
  9. //Framework Version in Backend Head
  10. $woo_framework_version = get_option( 'woo_framework_version' );
  11. //Version in Backend Head
  12. $theme_data = get_theme_data( get_template_directory() . '/style.css' );
  13. $local_version = $theme_data['Version'];
  14. //GET themes update RSS feed and do magic
  15. include_once(ABSPATH . WPINC . '/feed.php' );
  16. $pos = strpos($manualurl, 'documentation' );
  17. $theme_slug = str_replace( "/", "", substr($manualurl, ($pos + 13))); //13 for the word documentation
  18. //add filter to make the rss read cache clear every 4 hours
  19. add_filter( 'wp_feed_cache_transient_lifetime', create_function( '$a', 'return 14400;' ) );
  20. $framework_options = array();
  21. $framework_options[] = array( "name" => "Framework Settings",
  22. "icon" => "general",
  23. "type" => "heading" );
  24. $framework_options[] = array( "name" => "Super User (username)",
  25. "desc" => "Enter your <strong>username</strong> to hide the Framework Settings and Update Framework from other users. Can be reset from the <a href='".home_url()."/wp-admin/options.php'>WP options page</a> under <em>framework_woo_super_user</em>.",
  26. "id" => $shortname."_super_user",
  27. "std" => "",
  28. "class" => "text",
  29. "type" => "text" );
  30. $framework_options[] = array( "name" => "Disable SEO Menu Item",
  31. "desc" => "Disable the <strong>SEO</strong> menu item in the theme menu.",
  32. "id" => $shortname."_seo_disable",
  33. "std" => "",
  34. "type" => "checkbox" );
  35. $framework_options[] = array( "name" => "Disable Sidebar Manager Menu Item",
  36. "desc" => "Disable the <strong>Sidebar Manager</strong> menu item in the theme menu.",
  37. "id" => $shortname."_sbm_disable",
  38. "std" => "",
  39. "type" => "checkbox" );
  40. $framework_options[] = array( "name" => "Disable Buy Themes Menu Item",
  41. "desc" => "Disable the <strong>Buy Themes</strong> menu item in the theme menu.",
  42. "id" => $shortname."_buy_themes_disable",
  43. "std" => "",
  44. "type" => "checkbox" );
  45. $framework_options[] = array( "name" => "Enable Custom Navigation",
  46. "desc" => "Enable the old <strong>Custom Navigation</strong> menu item. Try to use <a href='".home_url()."/wp-admin/nav-menus.php'>WP Menus</a> instead, as this function is outdated.",
  47. "id" => $shortname."_woonav",
  48. "std" => "",
  49. "type" => "checkbox" );
  50. $framework_options[] = array( "name" => "Theme Update Notification",
  51. "desc" => "This will enable notices on your theme options page that there is an update available for your theme.",
  52. "id" => $shortname."_theme_version_checker",
  53. "std" => "",
  54. "type" => "checkbox" );
  55. $framework_options[] = array( "name" => "Disable Shortcodes Stylesheet",
  56. "desc" => "This disables the output of shortcodes.css in the HEAD section of your site.",
  57. "id" => $shortname."_disable_shortcodes",
  58. "std" => "",
  59. "type" => "checkbox" );
  60. $framework_options[] = array( "name" => "Remove Generator Meta Tags",
  61. "desc" => "This disables the output of generator meta tags in the HEAD section of your site.",
  62. "id" => $shortname."_disable_generator",
  63. "std" => "",
  64. "type" => "checkbox" );
  65. $framework_options[] = array( "name" => "Image Placeholder",
  66. "desc" => "Set a default image placeholder for your thumbnails. Use this if you want a default image to be shown if you haven't added a custom image to your post.",
  67. "id" => $shortname."_default_image",
  68. "std" => "",
  69. "type" => "upload" );
  70. $framework_options[] = array( "name" => "Branding",
  71. "icon" => "misc",
  72. "type" => "heading" );
  73. $framework_options[] = array( "name" => "Options panel header",
  74. "desc" => "Change the header image for the WooThemes Backend.",
  75. "id" => $shortname."_backend_header_image",
  76. "std" => "",
  77. "type" => "upload" );
  78. $framework_options[] = array( "name" => "Options panel icon",
  79. "desc" => "Change the icon image for the WordPress backend sidebar.",
  80. "id" => $shortname."_backend_icon",
  81. "std" => "",
  82. "type" => "upload" );
  83. $framework_options[] = array( "name" => "WordPress login logo",
  84. "desc" => "Change the logo image for the WordPress login page.",
  85. "id" => $shortname."_custom_login_logo",
  86. "std" => "",
  87. "type" => "upload" );
  88. $framework_options[] = array( "name" => "Import / Export",
  89. "icon" => "misc",
  90. "type" => "heading" );
  91. $framework_options[] = array( "name" => "Import Options",
  92. "desc" => "Import the options from another installation of this theme.",
  93. "id" => $shortname."_import_options",
  94. "std" => "",
  95. "type" => "textarea" );
  96. //Create, Encrypt and Update the Saved Settings
  97. global $wpdb;
  98. delete_option( 'framework_woo_export_options' );
  99. $options = get_option( 'woo_template' );
  100. $query_inner = '';
  101. $count = 0;
  102. foreach( $options as $option ) {
  103. if(isset($option['id'])){
  104. $count++;
  105. $option_id = $option['id'];
  106. if($count > 1){ $query_inner .= ' OR '; }
  107. $query_inner .= "option_name = '$option_id'";
  108. if ( is_array( $option['type'] ) ) {
  109. foreach ( $option['type'] as $o ) {
  110. if($count > 1){ $query_inner .= ' OR '; }
  111. if ( isset( $o['id'] ) ) {
  112. $option_id = $o['id'];
  113. $query_inner .= "option_name = '$option_id'";
  114. }
  115. }
  116. }
  117. }
  118. }
  119. // Add Sidebar Manager data to the WooFramework exporter.
  120. $query_inner .= " OR option_name = 'sbm_woo_sbm_options'";
  121. // Allow child themes/plugins to add their own data to the exporter.
  122. $query_inner = apply_filters( 'wooframework_export_query_inner', $query_inner );
  123. $query = "SELECT * FROM $wpdb->options WHERE $query_inner";
  124. $results = $wpdb->get_results($query);
  125. foreach ($results as $result){
  126. $output[$result->option_name] = $result->option_value;
  127. } // End FOREACH Loop
  128. $output = serialize($output);
  129. $framework_options[] = array( "name" => "Export Options",
  130. "desc" => "Export the options to another installation of this theme, or to keep a backup of your options.",
  131. "id" => $shortname."_export_options",
  132. "std" => base64_encode($output),
  133. "type" => "textarea" );
  134. /*
  135. $framework_options[] = array( "name" => "Font Stacks (Beta)",
  136. "icon" => "typography",
  137. "type" => "heading" );
  138. $framework_options[] = array( "name" => "Font Stack Builder",
  139. "desc" => "Use the font stack builder to add your own custom font stacks to your theme.
  140. To create a new stack, fill in the name and a CSS ready font stack.
  141. Once you have added a stack you can select it from the font menu on any of the
  142. Typography settings in your theme options.",
  143. "id" => $shortname."_font_stack",
  144. "std" => "Added Font Stacks",
  145. "type" => "string_builder" );
  146. */
  147. global $wp_version;
  148. if ( $wp_version >= '3.1' ) {
  149. $framework_options[] = array( "name" => "Admin Bar",
  150. "icon" => "header",
  151. "type" => "heading" );
  152. $framework_options[] = array( "name" => "Disable WordPress Admin Bar",
  153. "desc" => "Disable the WordPress Admin Bar.",
  154. "id" => $shortname."_admin_bar_disable",
  155. "std" => "",
  156. "type" => "checkbox" );
  157. $framework_options[] = array( "name" => "Enable the WooFramework Admin Bar enhancements",
  158. "desc" => "Enable several WooFramework-specific enhancements to the WordPress Admin Bar, such as custom navigation items for 'Theme Options'.",
  159. "id" => $shortname."_admin_bar_enhancements",
  160. "std" => "",
  161. "type" => "checkbox" );
  162. }
  163. update_option( 'woo_framework_template', $framework_options );
  164. ?>
  165. <div class="wrap" id="woo_container">
  166. <div id="woo-popup-save" class="woo-save-popup"><div class="woo-save-save">Options Updated</div></div>
  167. <div id="woo-popup-reset" class="woo-save-popup"><div class="woo-save-reset">Options Reset</div></div>
  168. <form action="" enctype="multipart/form-data" id="wooform" method="post">
  169. <?php
  170. // Add nonce for added security.
  171. if ( function_exists( 'wp_nonce_field' ) ) { wp_nonce_field( 'wooframework-framework-options-update' ); } // End IF Statement
  172. $woo_nonce = '';
  173. if ( function_exists( 'wp_create_nonce' ) ) { $woo_nonce = wp_create_nonce( 'wooframework-framework-options-update' ); } // End IF Statement
  174. if ( $woo_nonce == '' ) {} else {
  175. ?>
  176. <input type="hidden" name="_ajax_nonce" value="<?php echo $woo_nonce; ?>" />
  177. <?php
  178. } // End IF Statement
  179. ?>
  180. <div id="header">
  181. <div class="logo">
  182. <?php if(get_option( 'framework_woo_backend_header_image')) { ?>
  183. <img alt="" src="<?php echo get_option( 'framework_woo_backend_header_image' ); ?>"/>
  184. <?php } else { ?>
  185. <img alt="WooThemes" src="<?php echo get_template_directory_uri(); ?>/functions/images/logo.png"/>
  186. <?php } ?>
  187. </div>
  188. <div class="theme-info">
  189. <span class="theme"><?php echo $themename; ?> <?php echo $local_version; ?></span>
  190. <span class="framework">Framework <?php echo $woo_framework_version; ?></span>
  191. </div>
  192. <div class="clear"></div>
  193. </div>
  194. <div id="support-links">
  195. <ul>
  196. <li class="changelog"><a title="Theme Changelog" href="<?php echo $manualurl; ?>#Changelog">View Changelog</a></li>
  197. <li class="docs"><a title="Theme Documentation" href="<?php echo $manualurl; ?>">View Themedocs</a></li>
  198. <li class="forum"><a href="http://forum.woothemes.com" target="_blank">Visit Forum</a></li>
  199. <li class="right"><img style="display:none" src="<?php echo get_template_directory_uri(); ?>/functions/images/loading-top.gif" class="ajax-loading-img ajax-loading-img-top" alt="Working..." /><a href="#" id="expand_options">[+]</a> <input type="submit" value="Save All Changes" class="button submit-button" /></li>
  200. </ul>
  201. </div>
  202. <?php $return = woothemes_machine($framework_options); ?>
  203. <div id="main">
  204. <div id="woo-nav">
  205. <ul>
  206. <?php echo $return[1]; ?>
  207. </ul>
  208. </div>
  209. <div id="content">
  210. <?php echo $return[0]; ?>
  211. </div>
  212. <div class="clear"></div>
  213. </div>
  214. <div class="save_bar_top">
  215. <input type="hidden" name="woo_save" value="save" />
  216. <img style="display:none" src="<?php echo get_template_directory_uri(); ?>/functions/images/loading-bottom.gif" class="ajax-loading-img ajax-loading-img-bottom" alt="Working..." />
  217. <input type="submit" value="Save All Changes" class="button submit-button" />
  218. </form>
  219. <form action="<?php echo esc_html( $_SERVER['REQUEST_URI'] ) ?>" method="post" style="display:inline" id="wooform-reset">
  220. <?php
  221. // Add nonce for added security.
  222. if ( function_exists( 'wp_nonce_field' ) ) { wp_nonce_field( 'wooframework-framework-options-reset' ); } // End IF Statement
  223. $woo_nonce = '';
  224. if ( function_exists( 'wp_create_nonce' ) ) { $woo_nonce = wp_create_nonce( 'wooframework-framework-options-reset' ); } // End IF Statement
  225. if ( $woo_nonce == '' ) {} else {
  226. ?>
  227. <input type="hidden" name="_ajax_nonce" value="<?php echo $woo_nonce; ?>" />
  228. <?php
  229. } // End IF Statement
  230. ?>
  231. <span class="submit-footer-reset">
  232. <!-- <input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button" onclick="return confirm( 'Click OK to reset. Any settings will be lost!' );" /> -->
  233. <input type="hidden" name="woo_save" value="reset" />
  234. </span>
  235. </form>
  236. </div>
  237. <div style="clear:both;"></div>
  238. </div><!--wrap-->
  239. <?php } ?>