All_in_One_SEO_Pack_Feature_Manager

Class All_in_One_SEO_Pack_Feature_Manager.

Defined (1)

The class is defined in the following location(s).

/modules/aioseop_feature_manager.php  
  1. class All_in_One_SEO_Pack_Feature_Manager extends All_in_One_SEO_Pack_Module { 
  2.  
  3. protected $module_info = array(); 
  4.  
  5. /** 
  6. * All_in_One_SEO_Pack_Feature_Manager constructor. 
  7. * @param $mod Module. 
  8. */ 
  9. function __construct( $mod ) { 
  10. $this->name = __( 'Feature Manager', 'all-in-one-seo-pack' ); // Human-readable name of the plugin. 
  11. $this->prefix = 'aiosp_feature_manager_'; // Option prefix. 
  12. $this->file = __FILE__; // The current file. 
  13. parent::__construct(); 
  14. $this->module_info = array( 
  15. 'sitemap' => array( 
  16. 'name' => __( 'XML Sitemaps', 'all-in-one-seo-pack' ),  
  17. 'description' => __( 'Create and manage your XML Sitemaps using this feature and submit your XML Sitemap to Google, Bing/Yahoo and Ask.com.', 'all-in-one-seo-pack' ),  
  18. ),  
  19. 'opengraph' => array( 
  20. 'name' => __( 'Social Meta', 'all-in-one-seo-pack' ),  
  21. 'description' => __( 'Activate this feature to add Social Meta data to your site to deliver closer integration between your website/blog and Facebook, Twitter, and Google+.', 'all-in-one-seo-pack' ),  
  22. ),  
  23. 'robots' => array( 
  24. 'name' => __( 'Robots.txt', 'all-in-one-seo-pack' ),  
  25. 'description' => __( 'Generate and validate your robots.txt file to guide search engines through your site.', 'all-in-one-seo-pack' ),  
  26. ),  
  27. 'file_editor' => array( 
  28. 'name' => __( 'File Editor', 'all-in-one-seo-pack' ),  
  29. 'description' => __( 'Edit your robots.txt file and your .htaccess file to fine-tune your site.', 'all-in-one-seo-pack' ),  
  30. ),  
  31. 'importer_exporter' => array( 
  32. 'name' => __( 'Importer & Exporter', 'all-in-one-seo-pack' ),  
  33. 'description' => __( 'Exports and imports your All in One SEO Pack plugin settings.', 'all-in-one-seo-pack' ),  
  34. ),  
  35. 'bad_robots' => array( 
  36. 'name' => __( 'Bad Bot Blocker', 'all-in-one-seo-pack' ),  
  37. 'description' => __( 'Stop badly behaving bots from slowing down your website.', 'all-in-one-seo-pack' ),  
  38. ),  
  39. 'performance' => array( 
  40. 'name' => __( 'Performance', 'all-in-one-seo-pack' ),  
  41. 'description' => __( 'Optimize performance related to SEO and check your system status.', 'all-in-one-seo-pack' ),  
  42. 'default' => 'on',  
  43. ),  
  44. ); 
  45.  
  46. if ( AIOSEOPPRO ) { 
  47.  
  48. $this->module_info['coming_soon'] = array( 
  49. 'name' => __( 'Coming Soon...', 'all-in-one-seo-pack' ),  
  50. 'description' => __( 'Image SEO', 'all-in-one-seo-pack' ),  
  51. 'save' => false,  
  52. ); 
  53. $this->module_info['video_sitemap'] = array( 
  54. 'name' => __( 'Video Sitemap', 'all-in-one-seo-pack' ),  
  55. 'description' => __( 'Create and manage your Video Sitemap using this feature and submit your Video Sitemap to Google, Bing/Yahoo and Ask.com.', 'all-in-one-seo-pack' ),  
  56. ); 
  57.  
  58. } else { 
  59.  
  60. $this->module_info['coming_soon'] = array( 
  61. 'name' => __( 'Video Sitemap', 'all-in-one-seo-pack' ),  
  62. 'description' => __( 'Pro Version Only', 'all-in-one-seo-pack' ),  
  63. 'save' => false,  
  64. ); 
  65.  
  66.  
  67. // Set up default settings fields. 
  68. // Name - Human-readable name of the setting. 
  69. // Help_text - Inline documentation for the setting. 
  70. // Type - Type of field; this defaults to checkbox; currently supported types are checkbox, text, select, multiselect. 
  71. // Default - Default value of the field. 
  72. // Initial_options - Initial option list used for selects and multiselects. 
  73. // Other supported options: class, id, style -- allows you to set these HTML attributes on the field. 
  74.  
  75. $this->default_options = array(); 
  76. $this->module_info = apply_filters( 'aioseop_module_info', $this->module_info ); 
  77. $mod[] = 'coming_soon'; 
  78.  
  79. foreach ( $mod as $m ) { 
  80. if ( 'performance' === $m && ! is_super_admin() ) { 
  81. continue; 
  82. $this->default_options["enable_$m"] = array( 
  83. 'name' => $this->module_info[ $m ]['name'],  
  84. 'help_text' => $this->module_info[ $m ]['description'],  
  85. 'type' => 'custom',  
  86. 'class' => 'aioseop_feature',  
  87. 'id' => "aioseop_$m",  
  88. 'save' => true,  
  89. ); 
  90.  
  91. if ( ! empty( $this->module_info[ $m ]['image'] ) ) { 
  92. $this->default_options["enable_$m"]['image'] = $this->module_info[ $m ]['image']; 
  93. if ( ! empty( $this->module_info[ $m ] ) ) { 
  94. foreach ( array( 'save', 'default' ) as $option ) { 
  95. if ( isset( $this->module_info[ $m ][ $option ] ) ) { 
  96. $this->default_options["enable_$m"][ $option ] = $this->module_info[ $m ][ $option ]; 
  97. $this->layout = array( 
  98. 'default' => array( 
  99. 'name' => $this->name,  
  100. 'help_link' => 'http://semperplugins.com/documentation/feature-manager/',  
  101. 'options' => array_keys( $this->default_options ),  
  102. ),  
  103. ); 
  104. // Load initial options / set defaults. 
  105. $this->update_options(); 
  106. if ( is_admin() ) { 
  107. add_filter( $this->prefix . 'output_option', array( $this, 'display_option_div' ), 10, 2 ); 
  108. add_filter( $this->prefix . 'submit_options', array( $this, 'filter_submit' ) ); 
  109.  
  110. /** 
  111. * Determines the menu order. 
  112. * @return int 
  113. */ 
  114. function menu_order() { 
  115. return 20; 
  116.  
  117. /** 
  118. * @param $submit 
  119. * @return mixed 
  120. */ 
  121. function filter_submit( $submit ) { 
  122. $submit['Submit']['value'] = __( 'Update Features', 'all-in-one-seo-pack' ) . ' »'; 
  123. $submit['Submit']['class'] .= ' hidden'; 
  124. $submit['Submit_Default']['value'] = __( 'Reset Features', 'all-in-one-seo-pack' ) . ' »'; 
  125.  
  126. return $submit; 
  127.  
  128. /** 
  129. * @param $buf 
  130. * @param $args 
  131. * @return string 
  132. */ 
  133. function display_option_div( $buf, $args ) { 
  134. $name = $img = $desc = $checkbox = $class = ''; 
  135. if ( isset( $args['options']['help_text'] ) && ! empty( $args['options']['help_text'] ) ) { 
  136. $desc .= '<p class="aioseop_desc">' . $args['options']['help_text'] . '</p>'; 
  137. if ( $args['value'] ) { 
  138. $class = ' active'; 
  139. if ( isset( $args['options']['image'] ) && ! empty( $args['options']['image'] ) ) { 
  140. $img .= '<p><img src="' . AIOSEOP_PLUGIN_IMAGES_URL . $args['options']['image'] . '"></p>'; 
  141. } else { 
  142. $img .= '<p><span class="aioseop_featured_image' . $class . '"></span></p>'; 
  143.  
  144. if ( $args['options']['save'] ) { 
  145. $name = "<h3>{$args['options']['name']}</h3>"; 
  146. $checkbox .= '<input type="checkbox" onchange="jQuery(\'#' . $args['options']['id'] . ' .aioseop_featured_image, #' . $args['options']['id'] . ' .feature_button\').toggleClass(\'active\', this.checked);jQuery(\'input[name=Submit]\').trigger(\'click\');" style="display:none;" id="' . $args['name'] . '" name="' . $args['name'] . '"'; 
  147. if ( $args['value'] ) { 
  148. $checkbox .= ' CHECKED'; 
  149. $checkbox .= '><span class="button-primary feature_button' . $class . '"></span>'; 
  150. } else { 
  151. $name = "<b>{$args['options']['name']}</b>"; 
  152. if ( ! empty( $args['options']['id'] ) ) { 
  153. $args['attr'] .= " id='{$args['options']['id']}'"; 
  154.  
  155. return $buf . "<div {$args['attr']}><label for='{$args['name']}'><div class='free flag'>FREE</div><div class='pro flag'>PRO</div>{$name}{$img}{$desc}{$checkbox}</label></div>";