public function manage_users_columns($columns) { if (!WPFront_Static_URE::WP_Version('4.4')) { $columns[self::SECONDARY_ROLE_COLUMN_KEY] = $this->__('Secondary Roles'); } return $columns; }
public function set_license($key = NULL, $product = NULL) { if ($key === NULL && $this->license_key_k === NULL) { return; } if ($key !== NULL) { $this->slug = $key; $this->need_license = TRUE; $this->license_key_k = $key . '-license-key'; $this->product = $product; } if (is_multisite()) { $options = new WPFront_User_Role_Editor_Options($this->main); switch_to_blog($options->ms_options_blog_id()); } $entity = new WPFront_User_Role_Editor_Entity_Options(); $this->license_key = $entity->get_option($this->license_key_k); if ($this->license_key !== NULL) { $invalid_count = $entity->get_option($this->license_key_k . '-invalid-count'); if (empty($invalid_count)) { $invalid_count = 0; } $last_checked = $entity->get_option($this->license_key_k . '-last-checked'); if (($invalid_count > 0 || is_admin()) && !WPFront_Static_URE::doing_ajax() && $last_checked < time() - 24 * 3600) { $entity->update_option($this->license_key_k . '-last-checked', time()); $result = $this->remote_get('check_license', $this->license_key); $api_params = $result[1]; $result = $result[0]; if (!empty($result)) { if (($result->activations_left === 'unlimited' || $result->activations_left >= 0) && ($result->license === 'valid' || $result->license === 'expired')) { $entity->update_option($this->license_key_k . '-status', $result->license); $entity->update_option($this->license_key_k . '-expires', $result->expires); $entity->update_option($this->license_key_k . '-download-id', $result->download_id); $entity->update_option($this->license_key_k . '-invalid-count', 0); } else { $invalid_count = $invalid_count + 1; $entity->update_option($this->license_key_k . '-invalid-count', $invalid_count); $entity->update_option($this->license_key_k . '-home-url', $api_params['url']); $this->license_status = 'invalid'; if ($invalid_count === 1) { $this->send_mail('invalid', $result, 'wpfront.com', $api_params); } else { if ($invalid_count > 7) { $this->deactivate_license(TRUE); $this->send_mail('deactivated', $result, 'wpfront.com'); return; } } } } } $this->has_license = TRUE; $this->license_expired = $entity->get_option($this->license_key_k . '-status') === 'expired'; $this->license_expires = date('F d, Y', strtotime($entity->get_option($this->license_key_k . '-expires'))); $this->download_id = $entity->get_option($this->license_key_k . '-download-id'); if (!empty($this->download_id)) { $this->renew_url = sprintf('https://wpfront.com/checkout/?edd_license_key=%s&download_id=%d', $this->license_key, $this->download_id); } //$invalid_count = $entity->get_option($this->license_key_k . '-invalid-count'); if ($invalid_count > 0) { $this->license_status = 'invalid'; $this->license_home_url = $entity->get_option($this->license_key_k . '-home-url'); } if ($this->license_status === NULL) { if ($this->license_expired) { $this->license_status = 'expired'; } else { $this->license_status = 'valid'; } } $this->license_key = str_repeat('X', strlen($this->license_key) - 4) . substr($this->license_key, strlen($this->license_key) - 4, 4); //Software licensing change $this->edd_plugin_update(); //add_action('admin_init', array($this, 'edd_plugin_update')); } else { $this->license_key = ''; $this->has_license = FALSE; $this->license_expires = NULL; } if (is_multisite()) { restore_current_blog(); } }
protected function create_plugin_list() { if (isset($_GET['action'])) { if ($_GET['action'] == 'activate') { if (isset($_GET['plugin'])) { activate_plugin($_GET['plugin'] . '/' . $_GET['plugin'] . '.php'); // echo '<script type="text/javascript">window.location="' . WPFront_Static_URE::self_admin_url('admin.php?page=' . self::MENU_SLUG) . '";</script>'; // wp_die(); // return; } } } $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()); if (!function_exists('plugins_api')) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; } add_thickbox(); $args = array(); $args['page'] = 1; $args['per_page'] = 30; $args['author'] = 'syammohanm'; $api = plugins_api('query_plugins', $args); if (is_wp_error($api)) { wp_die($this->__('Unable to communicate with WordPress.org')); return; } ?> <style type="text/css"> div.wpfront-container table.plugins { margin-top: 16px; margin-bottom: 16px; } div.wpfront-container table.plugins th.check-column { width: 0px; } div.wpfront-container div.footer { text-align: center; } </style> <?php echo '<div class="wrap wpfront-container">'; echo '<h2>' . $this->__('WPFront Plugins') . '</h2>'; echo '<table class="wp-list-table widefat plugins plugin-install">'; $this->print_column_headers(); foreach ((array) $api->plugins as $plugin) { if (is_object($plugin)) { $plugin = (array) $plugin; } $title = wp_kses($plugin['name'], $plugins_allowedtags); $description = strip_tags($plugin['description']); if (strlen($description) > 400) { $description = mb_substr($description, 0, 400) . '…'; } //remove any trailing entities $description = preg_replace('/&[^;\\s]{0,6}$/', '', $description); //strip leading/trailing & multiple consecutive lines $description = trim($description); $description = preg_replace("|(\r?\n)+|", "\n", $description); //\n => <br> $description = nl2br($description); $version = wp_kses($plugin['version'], $plugins_allowedtags); $name = strip_tags($title . ' ' . $version); $author = $plugin['author']; if (!empty($plugin['author'])) { $author = ' <cite>' . sprintf($this->__('By %s'), $author) . '.</cite>'; } $author = wp_kses($author, $plugins_allowedtags); $action_links = array(); $action_links[] = '<a href="' . WPFront_Static_URE::self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=600&height=550') . '" class="thickbox" title="' . esc_attr(sprintf($this->__('More information about %s'), $name)) . '">' . $this->__('Details') . '</a>'; $class = 'inactive'; if (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = install_plugin_install_status($plugin); switch ($status['status']) { case 'install': if ($status['url']) { $action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr(sprintf($this->__('Install %s'), $name)) . '">' . $this->__('Install Now') . '</a>'; } $class = 'active'; break; case 'update_available': if ($status['url']) { $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr(sprintf($this->__('Update to version %s'), $status['version'])) . '">' . sprintf($this->__('Update Now'), $status['version']) . '</a>'; } $class = 'active update'; break; case 'latest_installed': case 'newer_installed': $action_links[] = '<span title="' . esc_attr__($this->__('This plugin is already installed and is up to date')) . ' ">' . $this->__('Installed') . '</span>'; if (is_plugin_active($plugin['slug'] . '/' . $plugin['slug'] . '.php')) { $action_links[] = '<a href="' . WPFront_Static_URE::self_admin_url('admin.php?page=' . $plugin['slug']) . '">' . $this->__('Settings') . '</a>'; } else { $action_links[] = '<a href="' . WPFront_Static_URE::self_admin_url('admin.php?page=' . self::MENU_SLUG . '&action=activate&plugin=' . $plugin['slug']) . '">' . $this->__('Activate') . '</a>'; } break; } } $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin); ?> <tr class="<?php echo $class; ?> "> <th class="check-column"></th> <td class="name column-name"><strong><?php echo $title; ?> </strong> <div class="action-links"><?php if (!empty($action_links)) { echo implode(' | ', $action_links); } ?> </div> </td> <td class="vers column-version"><?php echo $version; ?> </td> <td class="vers column-rating"> <?php $this->wp_star_rating(array('rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'])); ?> </td> <td class="desc column-description"><?php echo $description, $author; ?> </td> </tr> <?php } $this->print_column_footers(); echo '</table>'; echo '<div class="footer"><a href="http://wpfront.com/contact" target="_blank">' . $this->__('Feedback') . '</a> | <a href="http://wpfront.com" target="_blank">wpfront.com</a></div>'; echo '</div>'; }
public function lock_menus($parent_file = NULL) { if (WPFront_Static_URE::doing_ajax()) { return $parent_file; } if (empty($this->wp_menu)) { return $parent_file; } $user = wp_get_current_user(); $roles = $user->roles; $primary = TRUE; while (!empty($roles)) { $obj_role = get_role(array_shift($roles)); if ($obj_role === NULL) { continue; } $this->override_type = $this->get_override_type($obj_role); $this->hide_new_menu = $this->get_hide_new_menus($obj_role); $this->disable_for_secondary_role = $this->get_disable_for_secondary_role($obj_role); if (!$primary) { if ($this->disable_for_secondary_role) { continue; } } $role = $obj_role->name; $entity = new WPFront_User_Role_Editor_Entity_Menu_Editor(); $data = $entity->get_all_by_role($role); $data_indexed = $this->index_table_data($data); if ($this->override_type === self::OVERRIDE_TYPE_HARD) { global $self, $submenu_file, $plugin_page; $page = $plugin_page; if ($page == NULL) { $page = $submenu_file; } if ($page == NULL) { $page = $self; } $row_data = NULL; $parent_data = NULL; if ($page != NULL) { foreach ($data as $value) { if ($value->get_menu_slug() == $page) { if ($value->get_parent_menu_slug() != '') { $row_data = $value; } else { $parent_data = $value; } } } if ($row_data == NULL) { $row_data = $parent_data; } if ($row_data == NULL) { if ($this->hide_new_menu) { wp_die($this->page_lock_data()); die; return; } } else { if (!$this->has_access($obj_role, $this->hide_new_menu, $data_indexed, $row_data->get_menu_slug(), $row_data->get_parent_menu_slug())) { wp_die($this->page_lock_data()); die; return; } } } } $menu = $this->wp_menu; $submenu = $this->wp_submenu; $prev_menu = NULL; foreach ($menu as $parent) { if (!empty($submenu[$parent[2]])) { foreach ($submenu[$parent[2]] as $child) { if (!$this->has_access($obj_role, $this->hide_new_menu, $data_indexed, $this->escape_customize_slug($child[2]), $this->escape_customize_slug($parent[2]))) { remove_submenu_page($parent[2], $child[2]); } } } // if ($this->is_menu_separator($parent)) { // if ($this->is_menu_separator($prev_menu)) { // printf('%s <br />', $parent[2]); // remove_menu_page($parent[2]); // } else { // $prev_menu = $parent; // } // } else if (!$this->has_access($obj_role, $this->hide_new_menu, $data_indexed, $parent[2])) { // remove_menu_page($parent[2]); // } else { // $prev_menu = $parent; // } if (!$this->has_access($obj_role, $this->hide_new_menu, $data_indexed, $parent[2])) { remove_menu_page($parent[2]); } } $primary = FALSE; } return $parent_file; }