/** * Options Page and Input Validation for WPG3-Modules * * Depends on WP-Settings Api * * {@source} * **/ public function wpg3_admin_init() { global $wp_rewrite; // MODULES register their options here $modules = array($this->get_module() ); if($this->is_enabled){ $xhttp = $this->get_module_instance('WPG3_Xhttp'); array_push($modules, $xhttp->admin_init() ); $template = $this->get_module_instance('WPG3_Template'); array_push($modules, $template->admin_init() ); /* $imagechoser = $this->get_module_instance('WPG3_Imagechoser'); array_push($modules, $imagechoser->admin_init() ); */ if ( $wp_rewrite->using_permalinks() ){ $gallerypage = $this->get_module_instance('WPG3_Rewrite'); array_push($modules, $gallerypage->admin_init() ); } } register_setting( 'wpg3_options_grp', // settings group 'wpg3_options', // settings array(&$this,'admin_validate_options') // fn to validate input ); $page = 'wpg3_options_page'; // load Settings API if (!function_exists('add_settings_section')){ require_once(ABSPATH.'wp-admin/includes/template.php'); } /* stores validation functions */ $this->validate_fields = array(); // setting Option sections and fields foreach( $modules as $module){ if ( $module ){ add_settings_section( $module['unique_name'], $module['title'], $module['function'], $page); if( isset($module['settings_fields']) ){ foreach($module['settings_fields'] as $field){ add_settings_field($field['field_id'], $field['field_title'], $field['field_display'], $page, $module['unique_name']); if( isset($field['field_validate']) )$this->validate_fields[ $field['field_id'] ] = $field['field_validate']; } } } } } /** * get a module instance, load if required * * {@source} * * @param string Classname * @return object instance **/ public function get_module_instance($module, $override_options = false){ $return = false; if (isset($this->modules[$module]) and !$override_options){ $return = $this->modules[$module]; }else{ if (! isset($this->modules[$module])) $this->__autoload( $module ); if ( $override_options){ $this->wpg3_options = $override_options; } $instance = new $module( $this->wpg3_options ); $this->modules[$module] = $instance; $return = $instance; } return $return; } /** * Create Options Page for WPG3 * @internal **/ public function admin_add_page() { add_options_page(__('WPG3 Settings'), __('WPG3'), 'manage_options', __('WPG3'), array(&$this,'admin_optins_page_fn') ); } /** * Echo Option Page * @internal **/ public function admin_optins_page_fn() { //echo "This is the admin_optins_page() "; echo "\n
You must enable REST-Module in Gallery3 in Order to use WPG3.
Gallery 2 offered custom Resizes. Gallery3 not yet.
You can chose which reize to use in WPG3 for the width parameter in WPGX-Tags
Note: The Numbered width paramater is available in the Template to adjust width by CSS.
Max pixel width to use Thumb |
px'."\n";
echo 'Max pixel width to use Medium | ';
echo 'px | '."\n"; ?>For higher width values we use the Fullsize Image |
According to this settings WPG3 will chose the 'thumb', 'resize' or 'full' G3-Image to be inserted for a width parameter
wpg3_options['g3Resize']) ? $this->wpg3_options['g3Resize'] : array('max_thumb' => 60, 'max_resize' => 500 ); if ( is_array($field_val)){ if ( intval( $field_val['max_thumb']) > 0 and intval( $field_val['max_resize'] ) > $field_val['max_thumb']){ $return['max_thumb'] = $field_val['max_thumb']; }else{ add_settings_error('g3Resize', 'settings_updated', __('The Thumb width must be lower than the Medium width @ g3ResizeThe Url of you Gallery3 installation e.g. http://wpg3.local/gallery3/index.php
is_enabled ? $enabled = ' style="color: red;" ': $enabled =''; echo ''."\n"; } /** * Validate field "restReqestKey" * * @todo validate g3Url against REST **/ public function admin_options_section_validate_g3Url($field_val) { $return = false; // validate input if ( preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $field_val)){ if( substr( $field_val, -1 ) === "/" ) $field_val = substr ( $field_val, 0 , -1 ); // unset REST API Key unset($this->wpg3_options['restReqestKey']); $return = $field_val; }else{ // create a nice Error including you field_id add_settings_error('g3Url', 'settings_updated', __('A valid Gallery3 Url is required @ g3Url