function get_all_privilege() { global $wpdb; $query = "SELECT option_name, option_value FROM {$wpdb->prefix}options WHERE option_name LIKE 'sm_%_dashboard';"; $results = $wpdb->get_results($query); $rows_roles = $wpdb->num_rows; $roles = array(); foreach ($results as $obj) { $roles_detail = unserialize($obj->option_value); $roles[$obj->option_name] = $roles_detail; } $all_roles = get_editable_roles(); if (isset($all_roles['administrator'])) { unset($all_roles['administrator']); } foreach ($all_roles as $role => $details) { $name = translate_user_role($details['name']); $checked = array(); if ($rows_roles > 0) { for ($i = 0; $i < count($roles['sm_' . $role . '_dashboard']); $i++) { $checked[$roles['sm_' . $role . '_dashboard'][$i]] = 'checked'; } } $products_checked = isset($checked['Products']) && $checked['Products'] === 'checked' ? 'checked' : 'unchecked'; $customers_orders_checked = isset($checked['Customers_Orders']) && $checked['Customers_Orders'] === 'checked' ? 'checked' : 'unchecked'; if ($name != 'Administrator') { echo "\n <tr>\n <th scope='row'>{$name}</th>\n <td align='center'><input name='sm_" . $role . "_dashboard[]' type='checkbox' id='Products' value='Products' " . $products_checked . "></td>\n <td align='center'><input name='sm_" . $role . "_dashboard[]' type='checkbox' id='Customers_Orders' value='Customers_Orders' " . $customers_orders_checked . "></td>\n </tr>\n "; } } }
function wp_get_editable_roles() { global $wp_roles; $all_roles = $wp_roles->roles; $editable_roles = apply_filters('editable_roles', $all_roles); $possible_values = array(); foreach ($all_roles as $role => $details) { $name = translate_user_role($details['name']); switch ($role) { case 'administrator': $keyrole = 'switch_themes'; break; case 'editor': $keyrole = 'moderate_comments'; break; case 'author': $keyrole = 'upload_files'; break; case 'contributor': $keyrole = 'edit_posts'; break; case 'subscriber': $keyrole = 'read'; break; default: $keyrole = $role; } $possible_values[$keyrole] = $name; } return $possible_values; }
public function vtmin_fill_roles_checklist($tax_class, $checked_list = NULL) { $roles = get_editable_roles(); $roles['notLoggedIn'] = array('name' => 'Not logged in (just visiting)'); foreach ($roles as $role => $info) { $name_translated = translate_user_role($info['name']); $output = '<li id=' . $role . '>'; $output .= '<label class="selectit">'; $output .= '<input id="' . $role . '_' . $tax_class . ' " '; $output .= 'type="checkbox" name="tax-input-' . $tax_class . '[]" '; $output .= 'value="' . $role . '" '; if ($checked_list) { if (in_array($role, $checked_list)) { //if cat_id is in previously checked_list $output .= 'checked="checked"'; } } $output .= '>'; //end input statement $output .= ' ' . $name_translated; $output .= '</label>'; $output .= '</li>'; echo $output; } return; }
function bbconnect_dropdown_roles($selected = false) { $p = ''; $r = ''; $editable_roles = get_editable_roles(); foreach ($editable_roles as $role => $details) { $name = translate_user_role($details['name']); if (is_array($selected)) { if (in_array($role, $selected)) { // preselect specified role $p .= "\n\t<option selected='selected' value='" . esc_attr($role) . "'>{$name}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($role) . "'>{$name}</option>"; } } else { if ($selected == $role) { // preselect specified role $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>{$name}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($role) . "'>{$name}</option>"; } } } echo $p . $r; }
protected function render_settings($form) { $roles = array('administrator' => translate_user_role('Administrator'), 'editor' => translate_user_role('Editor'), 'author' => translate_user_role('Author'), 'contributor' => translate_user_role('Contributor'), 'subscriber' => translate_user_role('Subscriber')); ?> <table class="form-table itsec-settings-section"> <tr> <th scope="row"><label for="itsec-strong-passwords-role"><?php _e('Select Role for Strong Passwords', 'better-wp-security'); ?> </label></th> <td> <?php $form->add_select('role', $roles); ?> <br /> <label for="itsec-strong-passwords-role"><?php _e('Minimum role at which a user must choose a strong password.', 'better-wp-security'); ?> </label> <p class="description"><?php printf(__('For more information on WordPress roles and capabilities please see <a href="%1$s" target="_blank">%1$s</a>.', 'better-wp-security'), 'http://codex.wordpress.org/Roles_and_Capabilities'); ?> </p> <p class="warningtext description"><?php _e('Warning: If your site invites public registrations setting the role too low may annoy your members.', 'better-wp-security'); ?> </p> </td> </tr> </table> <?php }
function wp_roles_dropdown($field_name, $capability) { $field_value = FrmAppHelper::get_param($field_name); $editable_roles = get_editable_roles(); ?> <select name="<?php echo $field_name; ?> " id="<?php echo $field_name; ?> " class="frm-dropdown frm-pages-dropdown"> <?php foreach ($editable_roles as $role => $details) { $name = translate_user_role($details['name']); ?> <option value="<?php echo esc_attr($role); ?> " <?php echo (isset($_POST[$field_name]) and $_POST[$field_name] == $role or !isset($_POST[$field_name]) and $capability == $role) ? ' selected="selected"' : ''; ?> ><?php echo $name; ?> </option> <?php } ?> </select> <?php }
private function role_select_copy_prepare_html($select_width = 200) { global $current_user; $key_capability = $this->lib->get_key_capability(); $user_is_ure_admin = current_user_can($key_capability); $role_to_skip = $user_is_ure_admin ? '' : $current_user->roles[0]; $caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0); $show_admin_role = $this->lib->show_admin_role_allowed(); $this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: ' . $select_width . 'px"> <option value="none" selected="selected">' . esc_html__('None', 'user-role-editor') . '</option>'; $this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">'; $current_role = $this->lib->get('current_role'); $roles = $this->lib->get_editable_user_roles(); foreach ($roles as $key => $value) { if ($key === $role_to_skip) { // skip role of current user if he does not have full access to URE continue; } $selected1 = $this->lib->option_selected($key, $current_role); $disabled = $key === 'administrator' && $caps_access_restrict_for_simple_admin && !is_super_admin() ? 'disabled' : ''; if ($show_admin_role || $key != 'administrator') { $translated_name = esc_html__($value['name'], 'user-role-editor'); // get translation from URE language file, if exists if ($translated_name === $value['name']) { // get WordPress internal translation $translated_name = translate_user_role($translated_name); } $translated_name .= ' (' . $key . ')'; $this->role_select_html .= '<option value="' . $key . '" ' . $selected1 . ' ' . $disabled . '>' . $translated_name . '</option>'; $this->role_to_copy_html .= '<option value="' . $key . '" ' . $disabled . '>' . $translated_name . '</option>'; } } $this->role_select_html .= '</select>'; $this->role_to_copy_html .= '</select>'; }
/** * Returns the translated role of the current user. If that user has * no role for the current blog, it returns false. * * @return string The name of the current role **/ public function get_user_role(WP_User $user) { global $wp_roles; $roles = $user->roles; $role = array_shift($roles); return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : ''; }
* Template Functions * * Template functions specifically created for event listings and other event related methods. * * @author GAM Themes * @category Core * @package Event Manager/Template * @version 1.0.0 */
public function get_roles() { $roles = array(); foreach (wp_roles()->roles as $k => $role) { $roles[$k] = translate_user_role($role['name']); } return $roles; }
public static function callback_set_user_role($user_id, $new_role, $old_roles) { if (empty($old_roles)) { return; } global $wp_roles; self::log(_x('%1$s\'s role was changed from %2$s to %3$s', '1: User display name, 2: Old role, 3: New role', 'mainwp_child_reports'), array('display_name' => get_user_by('id', $user_id)->display_name, 'old_role' => translate_user_role($wp_roles->role_names[$old_roles[0]]), 'new_role' => translate_user_role($wp_roles->role_names[$new_role])), $user_id, array('profiles' => 'updated')); }
function get_user_role_by_id($id) { global $wp_roles; $curr_user = get_userdata($id); $roles = $curr_user->roles; $role = array_shift($roles); return isset($wp_roles->role_names[$role]) ? strtolower(translate_user_role($wp_roles->role_names[$role])) : false; }
function wcv_get_user_role($user_id) { global $wp_roles; $user = new WP_User($user_id); $roles = $user->roles; $role = array_shift($roles); return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : false; }
/** * * @return array; */ public function getPicklistOptions() { $editable_roles = get_editable_roles(); foreach ($editable_roles as $role => $details) { $name = translate_user_role($details['name']); $options[esc_attr($role)] = $name; } return $options; }
/** * Adds "Redirection" tab to Theme My Login menu * * @since 6.0 * @access public */ public function admin_menu() { global $wp_roles; add_submenu_page('theme_my_login', __('Theme My Login Custom Redirection Settings', 'theme-my-login'), __('Redirection', 'theme-my-login'), 'manage_options', $this->options_key, array(&$this, 'settings_page')); foreach ($wp_roles->get_names() as $role => $role_name) { if ('pending' != $role) { add_meta_box($role, translate_user_role($role_name), array(&$this, 'redirection_meta_box'), 'tml_page_' . $this->options_key, 'normal'); } } }
/** * Setup color scheme choices for use by control */ public function choices() { $choices = array('' => __('— No role for this site —')); $editable_roles = array_reverse(get_editable_roles()); foreach ($editable_roles as $role => $details) { $name = translate_user_role($details['name']); $choices[$role] = $name; } return $choices; }
public function getRoles() { $editableRoles = array_reverse(get_editable_roles()); $rolesOptions = array(); foreach ($editableRoles as $role => $details) { $name = translate_user_role($details['name']); $rolesOptions[esc_attr($role)] = $name; } return $rolesOptions; }
/** * Get all user roles. */ public function get_user_roles() { global $wp_roles; $roles = array(); foreach (apply_filters('editable_roles', $wp_roles->roles) as $role => $details) { $roles[$role] = translate_user_role($details['name']); } asort($roles, SORT_STRING); return $roles; }
/** * Get list of user roles * * @param array $roles * * @return array * * @access protected */ protected function getUserRoles($roles) { $response = array(); $names = AAM_Core_API::getRoles()->get_names(); foreach ($roles as $role) { if (isset($names[$role])) { $response[] = translate_user_role($names[$role]); } } return $response; }
public static function admin() { $DW =& $GLOBALS['DW']; parent::admin(); $list = array(); $wp_roles = $GLOBALS['wp_roles']; $roles = array_merge($wp_roles->role_names, array('anonymous' => __('Anonymous') . '|User role')); foreach ($roles as $rid => $role) { $list[esc_attr($rid)] = translate_user_role($role); } self::mkGUI(self::$type, self::$option[self::$name], self::$question, self::$info, self::$except, $list); }
function admin_created_user_email( $text ) { $roles = get_editable_roles(); $role = $roles[ $_REQUEST['role'] ]; /* translators: 1: Site name, 2: site URL, 3: role */ return sprintf( __( 'Hi, You\'ve been invited to join \'%1$s\' at %2$s with the role of %3$s. If you do not want to join this site please ignore this email. This invitation will expire in a few days. Please click the following link to activate your user account: %%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); }
/** * Get role list * * Prepare and return the list of roles for the table view * * @return string JSON Encoded role list * * @access public */ public function getTable() { //retrieve list of users $count = count_users(); $stats = $count['avail_roles']; $filtered = $this->fetchRoleList(); $response = array('recordsTotal' => count(get_editable_roles()), 'recordsFiltered' => count($filtered), 'draw' => AAM_Core_Request::request('draw'), 'data' => array()); foreach ($filtered as $role => $data) { $uc = isset($stats[$role]) ? $stats[$role] : 0; $response['data'][] = array($role, $uc, translate_user_role($data['name']), 'manage,edit' . ($uc ? ',no-delete' : ',delete')); } return json_encode($response); }
public function get_columns() { $roles = get_editable_roles(); $role_options = array(); foreach ($roles as $index => $role) { $role_options[$index] = translate_user_role($role['name']); } $columns = array('username' => array('title' => __('Username'), 'object_property' => 'user_login', 'active' => true, 'default_disabled' => true, 'type' => 'text', 'required' => true), 'email' => array('title' => __('Email'), 'object_property' => 'user_email', 'active' => true, 'default_disabled' => true, 'type' => 'text', 'required' => true), 'password' => array('title' => __('Password'), 'object_property' => 'user_password', 'active' => false, 'default_disabled' => true, 'type' => 'password', 'placeholder' => __('Auto-generate', 'bulkpress')), 'role' => array('title' => __('Role'), 'object_property' => 'role', 'active' => false, 'type' => 'select', 'options' => $role_options, 'default_default' => 'subscriber'), 'first_name' => array('title' => __('First Name'), 'object_property' => 'first_name', 'active' => false, 'type' => 'text', 'placeholder' => __('Use default', 'bulkpress')), 'last_name' => array('title' => __('Last Name'), 'object_property' => 'last_name', 'active' => false, 'type' => 'text', 'placeholder' => __('Use default', 'bulkpress')), 'website' => array('title' => __('Website'), 'object_property' => 'user_url', 'active' => false, 'type' => 'text', 'placeholder' => __('Use default', 'bulkpress'))); $defaults = array('default_default' => '', 'default' => ''); foreach ($columns as $index => $column) { $columns[$index] = array_merge($defaults, $column); } return $columns; }
function M_Roles_show_information($level_id) { global $wp_roles; // Get the currentlt set ping for each level $level =& new M_Level($level_id); $levelrole = $level->get_meta('associated_wp_role', ''); ?> <h3><?php _e('Associated Role', 'membership'); ?> </h3> <p class='description'><?php _e('If you want a specific WP role to be assigned to users on this level select it below.', 'membership'); ?> </p> <div class='level-details'> <label for='levelrole'><?php _e('Associated Role', 'membership'); ?> </label> <select name='levelrole'> <option value=''><?php _e('No associated role', 'membership'); ?> </option> <?php $all_roles = $wp_roles->roles; // Preset variables $p = ''; $r = ''; foreach ($all_roles as $role => $details) { $name = translate_user_role($details['name']); if ($levelrole == $role) { // preselect specified role $p .= "\n\t<option selected='selected' value='" . esc_attr($role) . "'>{$name}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($role) . "'>{$name}</option>"; } } echo $p . $r; ?> </select> </div> <?php }
function tm_get_roles() { $result = array(); $result["@everyone"] = __('Everyone', TM_EPO_TRANSLATION); $result["@loggedin"] = __('Logged in users', TM_EPO_TRANSLATION); global $wp_roles; if (empty($wp_roles)) { $all_roles = new WP_Roles(); } else { $all_roles = $wp_roles; } $roles = $all_roles->roles; if ($roles) { foreach ($roles as $role => $details) { $name = translate_user_role($details['name']); $result[$role] = $name; } } return $result; }
/** * Get Role List * * @return string JSON Encoded role list * * @access public */ public function retrieveList() { //retrieve list of users $count = count_users(); $user_count = $count['avail_roles']; //filter by name $search = strtolower(trim(aam_Core_Request::request('sSearch'))); $filtered = array(); $roles = get_editable_roles(); foreach ($roles as $id => $role) { if (!$search || preg_match('/^' . $search . '/i', $role['name'])) { $filtered[$id] = $role; } } $response = array('iTotalRecords' => count($roles), 'iTotalDisplayRecords' => count($filtered), 'sEcho' => aam_Core_Request::request('sEcho'), 'aaData' => array()); foreach ($filtered as $role => $data) { $users = isset($user_count[$role]) ? $user_count[$role] : 0; $response['aaData'][] = array($role, $users, translate_user_role($data['name']), ''); } return json_encode($response); }
/** * Settings field for cherry-picking which roles are allowed to upload avatars * * @since 0.1.0 */ function wp_user_avatars_settings_field_roles() { // Get roles $roles = get_editable_roles(); $val = get_option('wp_user_avatars_roles', array_keys($roles)); ?> <fieldset> <legend class="screen-reader-text"><?php esc_html_e('Upload Options', 'wp-user-avatars'); ?> </legend> <?php foreach ($roles as $role_id => $role) { ?> <label> <input type="checkbox" name="wp_user_avatars_roles[]" value="<?php echo esc_attr($role_id); ?> " <?php checked(in_array($role_id, $val)); ?> /> <?php echo translate_user_role($role['name']); ?> </label> <br> <?php } ?> </fieldset> <?php }
/** * Get the list of views available on this table (e.g. "all", "administrator", "subscriber"). * * Most of this method lifted directly from WP_Users_List_Table. * * @global unknown $roles * @global unknown $wp_roles * @since Achievements (3.0) */ public function get_views() { global $wp_roles, $role; // Get the number of users if ($this->is_site_users) { switch_to_blog($this->site_id); $users_of_blog = count_users(); restore_current_blog(); } else { $users_of_blog = count_users(); } // Build the URL back to this page, stripping of any parameters used on other links $url = remove_query_arg(array('action', 'error', 'role', 'updated'), $_SERVER['REQUEST_URI']); $total_users = $users_of_blog['total_users']; $avail_roles =& $users_of_blog['avail_roles']; $class = empty($role) ? ' class="current"' : ''; unset($users_of_blog); $role_links = array(); $role_links['all'] = "<a href='" . esc_url($url) . "'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'admin screen, types of users', 'achievements'), number_format_i18n($total_users)) . '</a>'; // Iterate through all WP user roles, and get count of users in each. foreach ($wp_roles->get_names() as $this_role => $name) { if (!isset($avail_roles[$this_role])) { continue; } $class = ''; // Highlight the currently selected user role if ($this_role === $role) { $class = ' class="current"'; } $name = translate_user_role($name); // translators: User role name with count $name = sprintf(__('%1$s <span class="count">(%2$s)</span>', 'achievements'), $name, number_format_i18n($avail_roles[$this_role])); // Build the links $role_links[$this_role] = "<a href='" . esc_url(add_query_arg('role', $this_role, $url)) . "'{$class}>{$name}</a>"; } return $role_links; }
/** * Get all the settings for the Subscriptions extension in the format required by the @see woocommerce_admin_fields() function. * * @return array Array of settings in the format required by the @see woocommerce_admin_fields() function. * @since 1.0 */ public static function get_settings() { global $woocommerce; $roles = get_editable_roles(); foreach ($roles as $role => $details) { $roles_options[$role] = translate_user_role($details['name']); } $available_gateways = array(); foreach ($woocommerce->payment_gateways->get_available_payment_gateways() as $gateway) { if ($gateway->supports('subscriptions')) { $available_gateways[] = $gateway->title; } } if (count($available_gateways) == 0) { $available_gateways_description = sprintf(__('No payment gateways capable of accepting subscriptions are enabled. Please enable the %sPayPal Standard%s gateway.', WC_Subscriptions::$text_domain), '<a href="' . admin_url('admin.php?page=woocommerce&tab=payment_gateways#gateway-paypal') . '">', '</a>'); } elseif (count($available_gateways) == 1) { $available_gateways_description = sprintf(__('The %s gateway is enabled and can accept subscriptions.', WC_Subscriptions::$text_domain), $available_gateways[0]); } elseif (count($available_gateways) > 1) { $available_gateways_description = sprintf(__('The %s & %s gateways are enabled and can accept subscriptions.', WC_Subscriptions::$text_domain), implode(', ', array_slice($available_gateways, 0, count($available_gateways) - 1)), array_pop($available_gateways)); } $max_failed_payment_options = range(0, 12); $max_failed_payment_options[0] = __('No maximum', WC_Subscriptions::$text_domain); return apply_filters('woocommerce_subscription_settings', array(array('name' => __('Button Text', WC_Subscriptions::$text_domain), 'type' => 'title', 'desc' => '', 'id' => self::$option_prefix . '_button_text'), array('name' => __('Add to Cart Button Text', WC_Subscriptions::$text_domain), 'desc' => __('A product displays a button with the text "Add to Cart". By default, a subscription changes this to "Sign Up Now". You can customise the button text for subscriptions here.', WC_Subscriptions::$text_domain), 'tip' => '', 'id' => self::$option_prefix . '_add_to_cart_button_text', 'css' => 'min-width:150px;', 'std' => __('Sign Up Now', WC_Subscriptions::$text_domain), 'type' => 'text', 'desc_tip' => true), array('name' => __('Place Order Button Text', WC_Subscriptions::$text_domain), 'desc' => __('Use this field to customise the text displayed on the checkout button when an order contains a subscription. Normally the checkout submission button displays "Place Order". When the cart contains a subscription, this is changed to "Sign Up Now".', WC_Subscriptions::$text_domain), 'tip' => '', 'id' => self::$option_prefix . '_order_button_text', 'css' => 'min-width:150px;', 'std' => __('Sign Up Now', WC_Subscriptions::$text_domain), 'type' => 'text', 'desc_tip' => true), array('type' => 'sectionend', 'id' => self::$option_prefix . '_button_text'), array('name' => __('Roles', WC_Subscriptions::$text_domain), 'type' => 'title', 'desc' => __('Choose the default roles to assign to active and inactive subscribers. For record keeping purposes, a user account must be created for subscribers. Users with the <em>administrator</em> role, such as yourself, will never be allocated these roles to prevent locking out administrators.', WC_Subscriptions::$text_domain), 'id' => self::$option_prefix . '_role_options'), array('name' => __('Subscriber Default Role', WC_Subscriptions::$text_domain), 'desc' => __('When a subscription is activated, either manually or after a successful purchase, new users will be assigned this role.', WC_Subscriptions::$text_domain), 'tip' => '', 'id' => self::$option_prefix . '_subscriber_role', 'css' => 'min-width:150px;', 'std' => 'subscriber', 'type' => 'select', 'options' => $roles_options, 'desc_tip' => true), array('name' => __('Inactive Subscriber Role', WC_Subscriptions::$text_domain), 'desc' => __('If a subscriber\'s subscription is manually cancelled or expires, she will be assigned this role.', WC_Subscriptions::$text_domain), 'tip' => '', 'id' => self::$option_prefix . '_cancelled_role', 'css' => 'min-width:150px;', 'std' => 'customer', 'type' => 'select', 'options' => $roles_options, 'desc_tip' => true), array('type' => 'sectionend', 'id' => self::$option_prefix . '_role_options'), array('name' => __('Failed Payments', WC_Subscriptions::$text_domain), 'type' => 'title', 'desc' => '', 'id' => self::$option_prefix . '_email_options'), array('name' => __('Maximum Failed Payments', WC_Subscriptions::$text_domain), 'desc' => __('After the number of maximum failed payments is exceeded, a subscription will be automatically cancelled.', WC_Subscriptions::$text_domain), 'tip' => '', 'id' => self::$option_prefix . '_max_failed_payments', 'css' => 'min-width:150px;', 'std' => '3', 'type' => 'select', 'options' => $max_failed_payment_options, 'desc_tip' => true), array('name' => __('Generate Renewal Orders', WC_Subscriptions::$text_domain), 'desc' => __('Automatically generate a new order for subscribers to reactivate a cancelled subscription.', WC_Subscriptions::$text_domain), 'id' => self::$option_prefix . '_generate_renewal_order', 'std' => 'no', 'type' => 'checkbox', 'desc_tip' => __('If a subscription is cancelled after exceeding the maximum number of allowable failed payments, a new order can be automatically generated and used by the subscriber to reactivate the subscription with new payment details.', WC_Subscriptions::$text_domain)), array('name' => __('Email Renewal Order', WC_Subscriptions::$text_domain), 'id' => self::$option_prefix . '_email_renewal_order', 'std' => 'no', 'type' => 'checkbox', 'desc_tip' => __('An automatically generated renewal order can be emailed to a subscriber once it has been generated.', WC_Subscriptions::$text_domain)), array('name' => __('Add Outstanding Balance', WC_Subscriptions::$text_domain), 'id' => self::$option_prefix . '_add_outstanding_balance', 'std' => 'yes', 'type' => 'checkbox', 'desc_tip' => __('If a payment fails, some gateways can add the outstanding amount to the next bill.', WC_Subscriptions::$text_domain)), array('type' => 'sectionend', 'id' => self::$option_prefix . '_payment_gateway_options'), array('name' => __('Payment Gateways', WC_Subscriptions::$text_domain), 'desc' => $available_gateways_description, 'id' => self::$option_prefix . '_payment_gateways_available', 'type' => 'informational'), array('desc' => sprintf(__('Only payment gateways that register support for subscriptions are displayed on the checkout page.', WC_Subscriptions::$text_domain), '<a href="' . admin_url('admin.php?page=woocommerce&tab=payment_gateways') . '">', '</a>'), 'id' => self::$option_prefix . '_payment_gateway_explanation', 'type' => 'informational'), array('desc' => sprintf(__('Get additional payment gateways that accept subscriptions from the %sOfficial WooCommerce Extension marketplace%s.', WC_Subscriptions::$text_domain), '<a href="http://zfer.us/lxmt7?d=' . esc_url('http://www.woothemes.com/extensions/woocommerce-payment-gateways/') . '">', '</a>'), 'id' => self::$option_prefix . '_payment_gateways_additional', 'type' => 'informational'), array('type' => 'sectionend', 'id' => self::$option_prefix . '_payment_gateway_options'))); }
function perpageath_config() { $currenturl = 'http'; if (isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") { $currenturl .= "s"; } $currenturl .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $currenturl .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $currenturl .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } $htmlfile = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'evonapluginconfig' . DIRECTORY_SEPARATOR . 'everyheadpage.html'; ?> <div class="wrap"> <h2><?php _e('Insert HTML on every page', 'per-page-ath'); ?> </h2> <h3><?php _e('Everything you put in here will be inserted into the <head> tag on every page. Ideal for favicons!', 'per-page-ath'); ?> </h3> <?php if (!file_exists($htmlfile)) { if ($htmlcreatehandle = fopen($htmlfile, 'x')) { fwrite($htmlcreatehandle, ""); fclose($htmlcreatehandle); } else { printf(__("Error creating %s! Is the underlying folder writable?", 'per-page-ath'), $htmlfile); } } if ($htmlhandle = fopen($htmlfile, 'r')) { if (filesize($htmlfile) > 0) { $html = fread($htmlhandle, filesize($htmlfile)); } else { $html = ""; } fclose($htmlhandle); } else { printf(__("Error reading HTML from file %s. Is this file readable?", 'per-page-ath'), $htmlfile); } if (isset($_POST['html']) && current_user_can('add-to-head')) { $newhtml = stripslashes_deep($_POST['html']); if ($newhtml == $html) { _e('HTML not updated', 'per-page-ath'); } elseif ($htmlwritehandle = fopen($htmlfile, 'w')) { $html = $newhtml; fwrite($htmlwritehandle, $html); fclose($htmlwritehandle); printf(__("Succesfully edited %s!", 'per-page-ath'), $htmlfile); } else { printf(__("Error writing HTML to %s. Is this file writable?", 'per-page-ath'), $htmlfile); } } global $wp_roles; $rolesallowednow = array(); foreach ($wp_roles->get_names() as $role_slug => $role_name) { $roleobject = $wp_roles->get_role($role_slug); if (isset($roleobject->capabilities['add-to-head']) && $roleobject->capabilities['add-to-head'] == 1) { $rolesallowednow[] = $role_slug; } } if (!in_array('administrator', $rolesallowednow)) { $roleobject = $wp_roles->get_role('administrator'); $roleobject->add_cap('add-to-head'); $rolesallowednow[] = 'administrator'; } $posttypesallowednow = get_option('ppath_types_allowed', array('post', 'page')); if (isset($_POST['submit'])) { //Role management //Check if all values are really roles $optionroles = array('administrator'); if (isset($_POST['rolesallowed']) && is_array($_POST['rolesallowed'])) { foreach ($_POST['rolesallowed'] as $roleallowed) { if ($wp_roles->is_role($roleallowed)) { $optionroles[] = $roleallowed; } } } //If changed, update roles if ($optionroles != $rolesallowednow) { if (current_user_can('manage_options')) { foreach ($optionroles as $role) { $roleobject = $wp_roles->get_role($role); $roleobject->add_cap('add-to-head'); } $revokedroles = array_diff($rolesallowednow, $optionroles); if (!empty($revokedroles)) { foreach ($revokedroles as $role) { $roleobject = $wp_roles->get_role($role); $roleobject->remove_cap('add-to-head'); } } $rolesallowednow = $optionroles; $rolesupdated = true; } } else { $rolesupdated = false; } //Post type management $newposttypes = array(); if (isset($_POST['typeallowed']) && is_array($_POST['typeallowed'])) { foreach ($_POST['typeallowed'] as $newposttype) { if (post_type_exists($newposttype)) { $newposttypes[] = $newposttype; } } } if ($newposttypes != $posttypesallowednow && current_user_can('add-to-head')) { update_option('ppath_types_allowed', $newposttypes); $posttypesallowednow = $newposttypes; $typesupdated = true; } else { $typesupdated = false; } } ?> <form method="post" action="<?php echo $currenturl; ?> "><?php if (current_user_can('add-to-head') || current_user_can('manage_options')) { if (isset($html)) { ?> <textarea style="white-space:pre; width:80%; min-width:600px; height:300px;" name="html"><?php echo $html; ?> </textarea><?php } ?> <br /> <h3><?php _e('Manage which users can access the plugin', 'per-page-ath'); ?> </h3> <?php if (isset($rolesupdated)) { if ($rolesupdated) { _e('Succesfully updated user role support', 'per-page-ath'); } else { _e('User role support not updated', 'per-page-ath'); } } ?> <table> <?php foreach ($wp_roles->get_names() as $role_slug => $role_name) { ?> <tr><td><?php echo translate_user_role($role_name); ?> </td><td><input type="checkbox" name="rolesallowed[]" value="<?php echo $role_slug; ?> " <?php if (in_array($role_slug, $rolesallowednow)) { echo ' checked="checked"'; } if ($role_slug == 'administrator') { echo ' disabled="disabled"'; } ?> /></td></tr> <?php } ?> </table> <br /> <h3><?php _e('Manage post types that have the per page add to head box', 'per-page-ath'); ?> </h3> <p><?php _e('Note: only post types which have their own page (like posts or pages, but not navigation menu items) are supported', 'per-page-ath'); ?> </p> <?php if (isset($typesupdated)) { if ($typesupdated) { _e('Succesfully updated post type support', 'per-page-ath'); } else { _e('Post type support not updated', 'per-page-ath'); } } ?> <table> <?php $post_types = get_post_types('', 'names'); foreach ($post_types as $post_type) { $post_type_object = get_post_type_object($post_type); ?> <tr><td><?php echo $post_type_object->labels->name; ?> </td><td><input type="checkbox" name="typeallowed[]" value="<?php echo $post_type; ?> " <?php if (in_array($post_type, $posttypesallowednow)) { echo ' checked="checked"'; } ?> /></td></tr> <?php } ?> </table> <?php submit_button(); } echo "</form></div>"; }