dvadf
File manager - Edit - /home/theblueo/tv/wp-includes/pomo/lib/config.tar
Back
VersionController.php 0000666 00000004346 15214104456 0010763 0 ustar 00 <?php /** * Plugin version / upgrade screen */ class Loco_admin_config_VersionController extends Loco_admin_config_BaseController { /** * {@inheritdoc} */ public function init(){ parent::init(); $this->set( 'title', __('Version','loco') ); // handle legacy degradation $nonce = $this->setNonce('downgrade'); try { if( $this->checkNonce($nonce->action) ){ update_option('loco-branch', '1', true ); $legacy = add_query_arg( array('page'=>'loco-translate'), admin_url('admin.php') ); wp_redirect( $legacy ); } } catch( Loco_error_Exception $e ){ Loco_error_AdminNotices::add($e); } } /** * {@inheritdoc} */ public function render(){ $title = __('Plugin settings','loco'); $breadcrumb = new Loco_admin_Navigation; $breadcrumb->add( $title ); // current plugin version $version = loco_plugin_version(); // check for auto-update availabilty if( $updates = get_site_transient('update_plugins') ){ $key = loco_plugin_self(); if( isset($updates->checked[$key]) && isset($updates->response[$key]) ){ $old = $updates->checked[$key]; $new = $updates->response[$key]->new_version; $diff = version_compare( $new, $old ); if( 1 === $diff ){ // current version is lower than latest $this->setUpdate( $new ); } /*else { // current version is a future release (dev branch probably) }*/ } } // $this->setUpdate('2.0.1-debug'); return $this->view('admin/config/version', compact('breadcrumb','version') ); } /** * @internal */ private function setUpdate( $version ){ $action = 'upgrade-plugin_'.loco_plugin_self(); $link = admin_url( 'update.php?action=upgrade-plugin&plugin='.rawurlencode(loco_plugin_self()) ); $this->set('update', $version ); $this->set('update_href', wp_nonce_url( $link, $action ) ); } } PrefsController.php 0000666 00000003027 15214104456 0010410 0 ustar 00 <?php /** * User-level plugin preferences */ class Loco_admin_config_PrefsController extends Loco_admin_config_BaseController { /** * {@inheritdoc} */ public function init(){ parent::init(); $this->set( 'title', __('User options','loco') ); // user preference options $opts = Loco_data_Preferences::get(); $this->set( 'opts', $opts ); // default value for Last-Translator credit $user = wp_get_current_user(); $name = $user->get('display_name') or $name = 'nobody'; $email = $user->get('user_email') or $email = 'nobody@localhost'; $this->set('credit', sprintf('%s <%s>', $name, $email ) ); // handle save action $nonce = $this->setNonce('save-prefs'); try { if( $this->checkNonce($nonce->action) ){ $post = Loco_mvc_PostParams::get(); if( $post->has('opts') ){ $opts->populate( $post->opts )->persist(); Loco_error_AdminNotices::success( __('Settings saved','loco') ); } } } catch( Loco_error_Exception $e ){ Loco_error_AdminNotices::add($e); } } /** * {@inheritdoc} */ public function render(){ $title = __('Plugin settings','loco'); $breadcrumb = new Loco_admin_Navigation; $breadcrumb->add( $title ); return $this->view('admin/config/prefs', compact('breadcrumb') ); } } BaseController.php 0000666 00000002176 15214104456 0010207 0 ustar 00 <?php /** * Base controller for global plugin configuration screens */ abstract class Loco_admin_config_BaseController extends Loco_mvc_AdminController { /** * {@inheritdoc} */ public function init(){ parent::init(); // navigate between config view siblings, but only if privileged user if( current_user_can('manage_options') ){ $tabs = new Loco_admin_Navigation; $this->set( 'tabs', $tabs ); $actions = array ( '' => __('Site options','loco'), 'user' => __('User options','loco'), 'version' => __('Version','loco'), ); $suffix = (string) $this->get('action'); foreach( $actions as $action => $name ){ $href = Loco_mvc_AdminRouter::generate( 'config-'.$action, $_GET ); $tabs->add( $name, $href, $action === $suffix ); } } } /** * {@inheritdoc} */ public function getHelpTabs(){ return array ( __('Overview','default') => $this->view('tab-settings'), ); } } SettingsController.php 0000666 00000005330 15214104456 0011130 0 ustar 00 <?php /** * Site-wide Loco options (plugin settings) */ class Loco_admin_config_SettingsController extends Loco_admin_config_BaseController { /** * {@inheritdoc} */ public function init(){ parent::init(); // set current plugin options and defaults for placeholders $opts = Loco_data_Settings::get(); $this->set( 'opts', $opts ); $this->set( 'dflt', Loco_data_Settings::create() ); // roles and capabilities $perms = new Loco_data_Permissions; // handle save action $nonce = $this->setNonce('save-config'); try { if( $this->checkNonce($nonce->action) ){ $post = Loco_mvc_PostParams::get(); if( $post->has('opts') ){ $opts->populate( $post->opts )->persist(); $perms->populate( $post->has('caps') ? $post->caps : array() ); // done update Loco_error_AdminNotices::success( __('Settings saved','loco') ); // remove saved params if persistant options unset if( ! $opts['fs_persist'] ){ $session = Loco_data_Session::get(); if( isset($session['loco-fs']) ){ unset( $session['loco-fs'] ); $session->persist(); } } } } } catch( Loco_error_Exception $e ){ Loco_error_AdminNotices::add($e); } $this->set('caps', $caps = new Loco_mvc_ViewParams ); // there is no distinct role for network admin, so we'll fake it for UI if( is_multisite() ){ $caps[''] = new Loco_mvc_ViewParams( array( 'label' => __('Super Admin','default'), 'name' => 'dummy-admin-cap', 'attrs' => 'checked disabled' ) ); } /* @var $role WP_Role */ foreach( $perms->getRoles() as $id => $role ){ $caps[$id] = new Loco_mvc_ViewParams( array( 'value' => '1', 'label' => $perms->getRoleName($id), 'name' => 'caps['.$id.'][loco_admin]', 'attrs' => $perms->isProtectedRole($role) ? 'checked disabled ' : ( $role->has_cap('loco_admin') ? 'checked ' : '' ), ) ); } } /** * {@inheritdoc} */ public function render(){ $title = __('Plugin settings','loco'); $breadcrumb = new Loco_admin_Navigation; $breadcrumb->add( $title ); return $this->view('admin/config/settings', compact('breadcrumb') ); } }
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings