PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/events-manager/admin/em-ms-options.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 219 lines | 197 code | 11 blank | 11 comment | 27 complexity | 8219ce1036b3bb35d975752f92962518 MD5 | raw file
  1. <?php
  2. function em_ms_upgrade( $blog_id ){
  3. ?>
  4. <div class="wrap">
  5. <div id='icon-options-general' class='icon32'><br /></div>
  6. <h2><?php _e('Update Network'); ?></h2>
  7. <?php
  8. if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'upgrade' && check_admin_referer('em_ms_ugrade_'.get_current_user_id()) ){
  9. global $current_site,$wpdb;
  10. $blog_ids = $wpdb->get_col('SELECT blog_id FROM '.$wpdb->blogs.' WHERE site_id='.$current_site->id);
  11. foreach($blog_ids as $blog_id){
  12. $plugin_basename = plugin_basename(dirname(dirname(__FILE__)).'/events-manager.php');
  13. if( in_array( $plugin_basename, (array) get_blog_option($blog_id, 'active_plugins', array() ) ) || is_plugin_active_for_network($plugin_basename) ){
  14. if( EM_VERSION > get_blog_option($blog_id, 'dbem_version', 0) ){
  15. switch_to_blog($blog_id);
  16. require_once( dirname(__FILE__).'/../em-install.php');
  17. em_install();
  18. echo "<p>Upgraded - ".get_bloginfo('blogname')."</p>";
  19. restore_current_blog();
  20. }else{
  21. echo "<p>&quot;".get_blog_option($blog_id, 'blogname')."&quot; is up to date.</p>";
  22. }
  23. }else{
  24. echo "<p>&quot;".get_blog_option($blog_id, 'blogname')."&quot; does not have Events Manager activated.</p>";
  25. }
  26. }
  27. echo "<p>Done Upgrading</p>";
  28. }else{
  29. ?>
  30. <form action="" method="post">
  31. <p><?php _e('To update your network blogs with the latest Events Manager automatically, click the update button below.'); ?></p>
  32. <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('em_ms_ugrade_'.get_current_user_id()); ?>" />
  33. <input type="hidden" name="action" value="upgrade" />
  34. <input type="submit" value="<?php _e('Update','dbem'); ?>" />
  35. </form>
  36. <?php
  37. }
  38. ?>
  39. </div>
  40. <?php
  41. }
  42. /**
  43. * Displays network-related options in the network admin section
  44. * @uses em_options_save() to save settings
  45. */
  46. function em_ms_admin_options_page() {
  47. global $wpdb,$EM_Notices;
  48. //Check for uninstall/reset request
  49. if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'uninstall' ){
  50. em_admin_options_uninstall_page();
  51. return;
  52. }
  53. if( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ){
  54. em_admin_options_reset_page();
  55. return;
  56. }
  57. //TODO place all options into an array
  58. $events_placeholders = '<a href="'.EM_ADMIN_URL .'&amp;events-manager-help#event-placeholders">'. __('Event Related Placeholders','dbem') .'</a>';
  59. $locations_placeholders = '<a href="'.EM_ADMIN_URL .'&amp;events-manager-help#location-placeholders">'. __('Location Related Placeholders','dbem') .'</a>';
  60. $bookings_placeholders = '<a href="'.EM_ADMIN_URL .'&amp;events-manager-help#booking-placeholders">'. __('Booking Related Placeholders','dbem') .'</a>';
  61. $categories_placeholders = '<a href="'.EM_ADMIN_URL .'&amp;events-manager-help#category-placeholders">'. __('Category Related Placeholders','dbem') .'</a>';
  62. $events_placeholder_tip = " ". sprintf(__('This accepts %s and %s placeholders.','dbem'),$events_placeholders, $locations_placeholders);
  63. $locations_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $locations_placeholders);
  64. $categories_placeholder_tip = " ". sprintf(__('This accepts %s placeholders.','dbem'), $categories_placeholders);
  65. $bookings_placeholder_tip = " ". sprintf(__('This accepts %s, %s and %s placeholders.','dbem'), $bookings_placeholders, $events_placeholders, $locations_placeholders);
  66. $save_button = '<tr><th>&nbsp;</th><td><p class="submit" style="margin:0px; padding:0px; text-align:right;"><input type="submit" id="dbem_options_submit" name="Submit" value="'. __( 'Save Changes', 'dbem') .' ('. __('All','dbem') .')" /></p></ts></td></tr>';
  67. //Do some multisite checking here for reuse
  68. ?>
  69. <script type="text/javascript" charset="utf-8">
  70. jQuery(document).ready(function($){
  71. var close_text = '<?php _e('Collapse All','dbem'); ?>';
  72. var open_text = '<?php _e('Expand All','dbem'); ?>';
  73. var open_close = $('<a href="#" style="display:block; float:right; clear:right; margin:10px;">'+open_text+'</a>');
  74. $('#em-options-title').before(open_close);
  75. open_close.click( function(e){
  76. e.preventDefault();
  77. if($(this).text() == close_text){
  78. $(".postbox").addClass('closed');
  79. $(this).text(open_text);
  80. }else{
  81. $(".postbox").removeClass('closed');
  82. $(this).text(close_text);
  83. }
  84. });
  85. $(".postbox > h3").click(function(){ $(this).parent().toggleClass('closed'); });
  86. $(".postbox").addClass('closed');
  87. //MS Mode selection hiders
  88. $('input[name="dbem_ms_global_table"]').change(function(){ //global
  89. if( $('input:radio[name="dbem_ms_global_table"]:checked').val() == 1 ){
  90. $("tbody.em-global-options").show();
  91. $('input:radio[name="dbem_ms_mainblog_locations"]:checked').trigger('change');
  92. }else{
  93. $("tbody.em-global-options").hide();
  94. }
  95. }).first().trigger('change');
  96. //events
  97. $('input[name="dbem_ms_global_events"]').change(function(){
  98. if( $('input:radio[name="dbem_ms_global_events"]:checked').val() == 1 ){
  99. $("tr#dbem_ms_global_events_links_row").show();
  100. $('input:radio[name="dbem_ms_global_events_links"]:checked').trigger('change');
  101. }else{
  102. $("tr#dbem_ms_global_events_links_row, tr#dbem_ms_events_slug_row").hide();
  103. }
  104. }).first().trigger('change');
  105. $('input[name="dbem_ms_global_events_links"]').change(function(){
  106. if( $('input:radio[name="dbem_ms_global_events_links"]:checked').val() == 1 ){
  107. $("tr#dbem_ms_events_slug_row").hide();
  108. }else{
  109. $("tr#dbem_ms_events_slug_row").show();
  110. }
  111. }).first().trigger('change');
  112. //locations
  113. $('input[name="dbem_ms_mainblog_locations"]').change(function(){
  114. if( $('input:radio[name="dbem_ms_mainblog_locations"]:checked').val() == 1 ){
  115. $("tbody.em-global-locations").hide();
  116. }else{
  117. $("tbody.em-global-locations").show();
  118. }
  119. }).first().trigger('change');
  120. $('input[name="dbem_ms_global_locations"]').change(function(){
  121. if( $('input:radio[name="dbem_ms_global_locations"]:checked').val() == 1 ){
  122. $("tr#dbem_ms_global_locations_links_row").show();
  123. $('input:radio[name="dbem_ms_global_locations_links"]:checked').trigger('change');
  124. }else{
  125. $("tr#dbem_ms_global_locations_links_row, tr#dbem_ms_locations_slug_row").hide();
  126. }
  127. }).first().trigger('change');
  128. $('input[name="dbem_ms_global_locations_links"]').change(function(){
  129. if( $('input:radio[name="dbem_ms_global_locations_links"]:checked').val() == 1 ){
  130. $("tr#dbem_ms_locations_slug_row").hide();
  131. }else{
  132. $("tr#dbem_ms_locations_slug_row").show();
  133. }
  134. });
  135. });
  136. </script>
  137. <style type="text/css">.postbox h3 { cursor:pointer; }</style>
  138. <div class="wrap">
  139. <div id='icon-options-general' class='icon32'><br /></div>
  140. <h2 class="nav-tab-wrapper">
  141. <a href="#" id="em-menu-general" class="nav-tab nav-tab-active"><?php _e('General','dbem'); ?></a>
  142. </h2>
  143. <h3 id="em-options-title"><?php _e ( 'Event Manager Options', 'dbem' ); ?></h3>
  144. <?php echo $EM_Notices; ?>
  145. <form id="em-options-form" method="post" action="">
  146. <div class="metabox-holder">
  147. <!-- // TODO Move style in css -->
  148. <div class='postbox-container' style='width: 99.5%'>
  149. <div id="">
  150. <div class="em-menu-general em-menu-group">
  151. <div class="postbox " >
  152. <div class="handlediv" title="<?php __('Click to toggle', 'dbem'); ?>"><br /></div><h3><span><?php _e ( 'Multi Site Options', 'dbem' ); ?></span></h3>
  153. <div class="inside">
  154. <table class="form-table">
  155. <?php
  156. em_options_radio_binary ( __( 'Enable global tables mode?', 'dbem'), 'dbem_ms_global_table', __( 'Setting this to yes will make all events save in the main site event tables (EM must also be activated). This allows you to share events across different blogs, such as showing events in your network whilst allowing users to display and manage their events within their own blog. Bear in mind that activating this will mean old events created on the sub-blogs will not be accessible anymore, and if you switch back they will be but new events created during global events mode will only remain on the main site.','dbem' ) );
  157. ?>
  158. <tbody class="em-global-options">
  159. <?php
  160. global $current_site;
  161. $global_slug_tip = __('%s belonging to other sub-sites will have an extra slug preppended to it so that your main site can differentiate between its own %s and those belonging to other sites in your network.');
  162. $global_link_tip = __( 'When displaying global %s on the main site you have the option of users viewing the %s details on the main site or being directed to the sub-site.','dbem' );
  163. $global_post_tip = __( 'Displays %s from all sites on the network by default. You can still restrict %s by blog using shortcodes and template tags coupled with the <code>blog</code> attribute. Requires global tables to be turned on.','dbem');
  164. $global_link_tip2 = __('You <strong>must</strong> have assigned a %s page in your <a href="%s">main blog settings</a> for this to work.');
  165. $options_page_link = get_admin_url($current_site->blog_id, 'edit.php?post_type=event&page=events-manager-options#pages');
  166. ?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Event','dbem')); ?></strong></td></tr><?php
  167. em_options_radio_binary ( sprintf(__( 'Display global events on main blog?', 'dbem'), __('events','dbem')), 'dbem_ms_global_events', sprintf($global_post_tip, __('events','dbem'), __('events','dbem')) );
  168. em_options_radio_binary ( sprintf(__( 'Link sub-site %s directly to sub-site?', 'dbem'), __('events','dbem')), 'dbem_ms_global_events_links', sprintf($global_link_tip, __('events','dbem'), __('event','dbem')).sprintf($global_link_tip2, __('event','dbem'), $options_page_link) );
  169. em_options_input_text ( sprintf(__( 'Global %s slug', 'dbem' ),__('event','dbem')), 'dbem_ms_events_slug', sprintf($global_slug_tip, __('Events','dbem'), __('events','dbem')).__('Example:','dbem').'<code>http://yoursite.com/events/<strong>event</strong>/subsite-event-slug/', EM_EVENT_SLUG );
  170. ?><tr><td><strong><?php echo sprintf(__('%s Options','dbem'),__('Location','dbem')); ?></strong></td></tr><?php
  171. em_options_radio_binary ( sprintf(__( 'Locations on main blog?', 'dbem'), __('locations','dbem')), 'dbem_ms_mainblog_locations', __('If you would prefer all your locations to belong to your main blog, users in sub-sites will still be able to create locations, but the actual locations are created and reside in the main blog.','dbem') );
  172. ?>
  173. </tbody>
  174. <tbody class="em-global-options em-global-locations">
  175. <?php
  176. em_options_radio_binary ( sprintf(__( 'Display global %s on main blog?', 'dbem'), __('locations','dbem')), 'dbem_ms_global_locations', sprintf($global_post_tip, __('locations','dbem'), __('locations','dbem')) );
  177. em_options_radio_binary ( sprintf(__( 'Link sub-site %s directly to sub-site?', 'dbem'), __('locations','dbem')), 'dbem_ms_global_locations_links', sprintf($global_link_tip, __('locations','dbem'), __('location','dbem')).sprintf($global_link_tip2, __('location','dbem'), $options_page_link) );
  178. em_options_input_text ( sprintf(__( 'Global %s slug', 'dbem' ),__('event','dbem')), 'dbem_ms_locations_slug', sprintf($global_slug_tip, __('Locations','dbem'), __('locations','dbem')).__('Example:','dbem').'<code>http://yoursite.com/locations/<strong>location</strong>/subsite-location-slug/', EM_LOCATION_SLUG );
  179. ?>
  180. </tbody>
  181. <?php echo $save_button; ?>
  182. </table>
  183. </div> <!-- . inside -->
  184. </div> <!-- .postbox -->
  185. <?php
  186. //including shared MS/non-MS boxes
  187. em_admin_option_box_caps();
  188. em_admin_option_box_image_sizes();
  189. em_admin_option_box_email();
  190. em_admin_option_box_uninstall();
  191. ?>
  192. <?php do_action('em_ms_options_page_footer'); ?>
  193. </div> <!-- .em-menu-general -->
  194. <div class="em-menu-pages em-menu-group" style="display:none;">
  195. </div> <!-- .em-menu-pages -->
  196. <p class="submit">
  197. <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e ( 'Save Changes' )?>" />
  198. <input type="hidden" name="em-submitted" value="1" />
  199. <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('events-manager-options'); ?>" />
  200. </p>
  201. </div> <!-- .metabox-sortables -->
  202. </div> <!-- .postbox-container -->
  203. </div> <!-- .metabox-holder -->
  204. </form>
  205. </div>
  206. <?php
  207. }
  208. ?>