private function addMenu() { if (User::isUserLoggedIn() && User::currentUserCan('edit_themes')) { \add_action('admin_menu', [$this, 'addPage'], 2); \add_filter('plugin_action_links', [$this, 'filterActionLink'], 10, 2); } }
public static function createPage(array $pages) { if (!User::currentUserCan('manage_options')) { return false; } foreach ($pages as $pagePath => $v) { static::getPageByPath($pagePath) || \wp_insert_post(array_merge(['post_content' => '', 'post_name' => null, 'post_title' => null, 'post_status' => 'publish', 'post_type' => 'page', 'comment_status' => 'closed'], $v)); } }
public function ajaxProcessLogged() { set_time_limit(0); Security::checkNonce(); Security::checkReferer(); if (!User::currentUserCan('manage_options')) { die; } $mainApi = new MainApi(); $mainApi->globPhpFiles(ABSPATH, [$this, 'dirnameToDir']); die('Done!'); }
public function initUpdate() { if (!User::currentUserCan('manage_options')) { return; } $this->setRelativeFile(); \add_filter('site_transient_update_plugins', [$this, 'checkForUpdate'], 1); \add_filter('plugins_api', [$this, 'filterPluginsApi'], 10, 3); \add_filter('upgrader_source_selection', [$this, 'filterUpgraderSourceSelection'], 10, 3); \add_filter('upgrader_pre_install', [$this, 'filterUpgraderPreInstall'], 10, 2); //\add_filter('upgrader_post_install', [$this, 'filterFlushOpcache']); \add_filter('upgrader_post_install', [$this, 'filterUpgraderPostInstall'], 10, 3); }
public static function isOptsPage() { $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); return $page === Functions::buildActionName(Options::URL_ID) && User::currentUserCan('manage_options') && static::isAdmin(); }