SimpleCalendarAdminMenus

Admin Menus.

Defined (1)

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

/includes/admin/menus.php  
  1. class Menus { 
  2.  
  3. /** 
  4. * The main menu screen hook. 
  5. * @access public 
  6. * @var string 
  7. */ 
  8. public static $main_menu = ''; 
  9.  
  10. /** 
  11. * Plugin basename. 
  12. * @access private 
  13. * @var string 
  14. */ 
  15. private static $plugin = ''; 
  16.  
  17. /** 
  18. * Set properties. 
  19. * @since 3.0.0 
  20. */ 
  21. public function __construct() { 
  22.  
  23. self::$main_menu = 'edit.php?post_type=calendar'; 
  24.  
  25. add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); 
  26.  
  27. self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); 
  28.  
  29. new Welcome(); 
  30.  
  31. // Links and meta content in plugins page. 
  32. add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); 
  33. add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); 
  34. // Custom text in admin footer. 
  35. add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); 
  36.  
  37. /** 
  38. * Add menu items. 
  39. * @since 3.0.0 
  40. */ 
  41. public static function add_menu_items() { 
  42.  
  43. add_submenu_page( 
  44. self::$main_menu,  
  45. __( 'Settings', 'google-calendar-events' ),  
  46. __( 'Settings', 'google-calendar-events' ),  
  47. 'manage_options',  
  48. 'simple-calendar_settings',  
  49. function () { 
  50. $page = new Pages( 'settings' ); 
  51. $page->html(); 
  52. ); 
  53.  
  54. add_submenu_page( 
  55. self::$main_menu,  
  56. __( 'Add-ons', 'google-calendar-events' ),  
  57. __( 'Add-ons', 'google-calendar-events' ),  
  58. 'manage_options',  
  59. 'simple-calendar_add_ons',  
  60. function() { 
  61. $page = new Pages( 'add-ons' ); 
  62. $page->html(); 
  63. ); 
  64.  
  65. add_submenu_page( 
  66. self::$main_menu,  
  67. __( 'Tools', 'google-calendar-events' ),  
  68. __( 'Tools', 'google-calendar-events' ),  
  69. 'manage_options',  
  70. 'simple-calendar_tools',  
  71. function () { 
  72. $page = new Pages( 'tools' ); 
  73. $page->html(); 
  74. ); 
  75.  
  76. do_action( 'simcal_admin_add_menu_items' ); 
  77.  
  78. /** 
  79. * Action links in plugins page. 
  80. * @since 3.0.0 
  81. * @param array $action_links 
  82. * @param string $file 
  83. * @return array 
  84. */ 
  85. public static function plugin_action_links( $action_links, $file ) { 
  86.  
  87. if ( self::$plugin == $file ) { 
  88.  
  89. $links = array(); 
  90. $links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; 
  91. $links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; 
  92.  
  93. return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); 
  94.  
  95. return $action_links; 
  96.  
  97. /** 
  98. * Links in plugin meta in plugins page. 
  99. * @since 3.0.0 
  100. * @param array $meta_links 
  101. * @param string $file 
  102. * @return array 
  103. */ 
  104. public static function plugin_row_meta( $meta_links, $file ) { 
  105.  
  106. if ( self::$plugin == $file ) { 
  107.  
  108. $links = array(); 
  109. $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . 
  110. __( 'Add-ons', 'google-calendar-events' ) . '</a>'; 
  111.  
  112. return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); 
  113.  
  114. return $meta_links; 
  115.  
  116. /** 
  117. * Admin footer text filter callback. 
  118. * Change this plugin screens admin footer text. 
  119. * @since 3.0.0 
  120. * @param $footer_text 
  121. * @return string|void 
  122. */ 
  123. public function admin_footer_text( $footer_text ) { 
  124.  
  125. // Check to make sure we're on a SimpleCal admin page 
  126. $screen = simcal_is_admin_screen(); 
  127. if ( $screen !== false ) { 
  128.  
  129. if ( 'calendar' == $screen ) { 
  130.  
  131. // Add Drip promo signup form (@see Newsletter meta box). 
  132. // Removed 9/26/16. 
  133.  
  134. /** 
  135. $drip_form_id = '5368192'; 
  136.   
  137. ?> 
  138. <form id="simcal-drip-form" 
  139. method="post" 
  140. target="_blank" 
  141. action="https://www.getdrip.com/forms/<?php echo $drip_form_id; ?>/submissions/" 
  142. data-drip-embedded-form="<?php echo $drip_form_id; ?>"> 
  143. <input type="hidden" 
  144. id="simcal-drip-real-field-first_name" 
  145. name="fields[first_name]" 
  146. value="" /> 
  147. <input type="hidden" 
  148. id="simcal-drip-real-field-email" 
  149. name="fields[email]" 
  150. value="" /> 
  151. <input type="submit" 
  152. class="hidden"/> 
  153. </form> 
  154. <?php 
  155. */ 
  156.  
  157. // Change the footer text 
  158. if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { 
  159.  
  160. $footer_text = sprintf( 
  161. __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ),  
  162. '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' 
  163. ); 
  164.  
  165. $footer_text .= '<script type="text/javascript">'; 
  166. $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { 
  167. jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); 
  168. jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); 
  169. });"; 
  170. $footer_text .= '</script>'; 
  171.  
  172. } else { 
  173.  
  174. $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); 
  175.  
  176.  
  177.  
  178. return $footer_text; 
  179.