web/wp-content/plugins/exec-php/includes/user_ui.php
branchwordpress
changeset 123 561aa6d282f6
equal deleted inserted replaced
112:fb7cd02b9848 123:561aa6d282f6
       
     1 <?php
       
     2 
       
     3 require_once(dirname(__FILE__).'/cache.php');
       
     4 require_once(dirname(__FILE__).'/const.php');
       
     5 require_once(dirname(__FILE__).'/l10n.php');
       
     6 
       
     7 // -----------------------------------------------------------------------------
       
     8 // the ExecPhp_UserUi class shows user specific settings in the user profile
       
     9 // -----------------------------------------------------------------------------
       
    10 
       
    11 // use this guard to avoid error messages in WP admin panel if plugin
       
    12 // is disabled because of a version conflict but you still try to reload
       
    13 // the plugins config interface
       
    14 if (!class_exists('ExecPhp_UserUi')) :
       
    15 class ExecPhp_UserUi
       
    16 {
       
    17 	var $m_cache = NULL;
       
    18 
       
    19 	// ---------------------------------------------------------------------------
       
    20 	// init
       
    21 	// ---------------------------------------------------------------------------
       
    22 
       
    23 	function ExecPhp_UserUi(&$cache)
       
    24 	{
       
    25 		$this->m_cache =& $cache;
       
    26 
       
    27 		add_action('show_user_profile', array(&$this, 'action_user_profile'));
       
    28 		add_action('edit_user_profile', array(&$this, 'action_user_profile'));
       
    29 		add_action('profile_update', array(&$this, 'action_profile_update'));
       
    30 	}
       
    31 
       
    32 	// ---------------------------------------------------------------------------
       
    33 	// hooks
       
    34 	// ---------------------------------------------------------------------------
       
    35 
       
    36 	function action_user_profile()
       
    37 	{
       
    38 		global $profileuser;
       
    39 		global $wp_version;
       
    40 
       
    41 		if ($profileuser->has_cap(ExecPhp_CAPABILITY_EXECUTE_ARTICLES))
       
    42 		{
       
    43 			$usermeta =& $this->m_cache->get_usermeta($profileuser->ID);
       
    44 ?>
       
    45 <?php if (version_compare($wp_version, '2.5.dev') >= 0) : ?>
       
    46 	<h3><?php _es('Exec-PHP Settings', ExecPhp_PLUGIN_ID); ?></h3>
       
    47 <?php else : ?>
       
    48 	<fieldset><legend><?php _es('Exec-PHP Settings', ExecPhp_PLUGIN_ID); ?></legend>
       
    49 <?php endif; ?>
       
    50 	<table class="form-table">
       
    51 		<tr valign="top">
       
    52 			<th scope="row"><?php _es('Disable WYSIWYG Conversion Warning', ExecPhp_PLUGIN_ID); ?></th>
       
    53 			<td>
       
    54 				<label for="<?php echo ExecPhp_POST_WYSIWYG_WARNING; ?>">
       
    55 					<input style="width: auto;" type="checkbox" name="<?php echo ExecPhp_POST_WYSIWYG_WARNING; ?>" id="<?php echo ExecPhp_POST_WYSIWYG_WARNING; ?>" value="true" <?php if ($usermeta->hide_wysiwyg_warning()) : ?>checked="checked" <?php endif; ?>/>
       
    56 					<?php _es('Select this option to turn off the WYSIWYG Conversion Warning in the Write menu. Nevertheless the recommended way is to switch off the WYSIWYG editor so you can be sure not to break existing PHP code by accident.', ExecPhp_PLUGIN_ID); ?>
       
    57 
       
    58 				</label>
       
    59 			</td>
       
    60 		</tr>
       
    61 	</table>
       
    62 <?php if (version_compare($wp_version, '2.5.dev') < 0) : ?>
       
    63 	</fieldset>
       
    64 <?php endif; ?>
       
    65 <?php
       
    66 		}
       
    67 	}
       
    68 
       
    69 	function action_profile_update($user_id)
       
    70 	{
       
    71 		$user = new WP_User($user_id);
       
    72 		if ($user->has_cap(ExecPhp_CAPABILITY_EXECUTE_ARTICLES))
       
    73 		{
       
    74 			$usermeta =& $this->m_cache->get_usermeta($user_id);
       
    75 			$usermeta->set_from_POST();
       
    76 			$usermeta->save();
       
    77 		}
       
    78 	}
       
    79 }
       
    80 endif;
       
    81 
       
    82 ?>