예제 #1
0
 /**
  * Apply configuration.
  */
 protected function configure($config = null)
 {
     // gurantee configuration
     $config !== null or $config = array();
     // invoke htmltag instance configuration
     if (isset($config['attrs'])) {
         parent::configure($config['attrs']);
         unset($config['attrs']);
     } else {
         // no html attributes set
         parent::configure(array());
     }
     // setup meta fields
     $this->meta = pixtypes::instance('PixtypesMeta', $config);
 }
예제 #2
0
파일: HTMLTag.php 프로젝트: ksingh812/epb
 /**
  * @return string attributes
  */
 function htmlattributes(array $extra = array())
 {
     $attr_segments = array();
     $attributes = pixtypes::merge($this->attrs->metadata_array(), $extra);
     foreach ($attributes as $key => $value) {
         if ($value !== false && $value !== null) {
             if (!empty($value)) {
                 if (is_array($value)) {
                     $htmlvalue = implode(' ', $value);
                     $attr_segments[] = "{$key}=\"{$htmlvalue}\"";
                 } else {
                     // value is not an array
                     $attr_segments[] = "{$key}=\"{$value}\"";
                 }
             } else {
                 // empty html tag; ie. no value html tag
                 $attr_segments[] = $key;
             }
         }
     }
     return implode(' ', $attr_segments);
 }
예제 #3
0
파일: defaults.php 프로젝트: ksingh812/epb
<?php

return array('cleanup' => array('switch' => array('switch_not_available')), 'checks' => array('counter' => array('is_numeric', 'not_empty')), 'processor' => array('preupdate' => array(), 'postupdate' => array()), 'errors' => array('is_numeric' => __('Numberic value required.', pixtypes::textdomain()), 'not_empty' => __('Field is required.', pixtypes::textdomain())), 'callbacks' => array('switch_not_available' => 'pixtypes_cleanup_switch_not_available', 'is_numeric' => 'pixtypes_validate_is_numeric', 'not_empty' => 'pixtypes_validate_not_empty'));
# config
예제 #4
0
파일: core.php 프로젝트: pwzCypher/wp-push
 /**
  * Sets a custom text domain; if null is passed the text domain will revert
  * to the default text domain.
  */
 static function settextdomain($textdomain)
 {
     if (!empty($textdomain)) {
         self::$textdomain = $textdomain;
     } else {
         // null or otherwise empty value
         // revert to default
         self::$textdomain = 'pixtypes_txtd';
     }
 }
예제 #5
0
파일: Validator.php 프로젝트: ksingh812/epb
 /**
  * @param string rule
  * @return string error message
  */
 function error_message($rule)
 {
     if (self::$error_message_cache === null) {
         $defaults = pixtypes::defaults();
         $default_errors = $defaults['errors'];
         $plugin_errors = $this->meta->get('errors', array());
         self::$error_message_cache = array_merge($default_errors, $plugin_errors);
     }
     return self::$error_message_cache[$rule];
 }
예제 #6
0
파일: Processor.php 프로젝트: ksingh812/epb
 /**
  * Execute postupdate hooks on input.
  */
 protected function postupdate($input)
 {
     $defaults = pixtypes::defaults();
     $plugin_hooks = $this->meta->get('processor', array('preupdate' => array(), 'postupdate' => array()));
     // Calculate hooks
     // ---------------
     $hooks = array();
     // check pixtypes defaults
     if (isset($defaults['processor']['postupdate'])) {
         $hooks = $defaults['processor']['postupdate'];
     }
     // check plugin defaults
     if (isset($plugin_hooks['postupdate'])) {
         $hooks = array_merge($hooks, $plugin_hooks['postupdate']);
     }
     // Execute hooks
     // -------------
     foreach ($hooks as $rule) {
         $callback = pixtypes::callback($rule, $this->meta);
         call_user_func($callback, $input, $this);
     }
 }
예제 #7
0
파일: Form.php 프로젝트: ksingh812/epb
 /**
  * @param string template path
  * @param array  configuration
  * @return string
  */
 function fieldtemplate($templatepath, $conf = array())
 {
     $config = pixtypes::instance('PixtypesMeta', $conf);
     return $this->fieldtemplate_render($templatepath, $config);
 }
예제 #8
0
<?php

defined('ABSPATH') or die;
$basepath = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$debug = false;
if (isset($_GET['debug']) && $_GET['debug'] == 'true') {
    $debug = true;
}
$options = get_option('pixtypes_settings');
$display_settings = false;
if (isset($options['display_settings'])) {
    $display_settings = $options['display_settings'];
}
return array('plugin-name' => 'pixtypes', 'settings-key' => 'pixtypes_settings', 'textdomain' => 'pixtypes_txtd', 'template-paths' => array($basepath . 'core/views/form-partials/', $basepath . 'views/form-partials/'), 'fields' => array('hiddens' => include 'settings/hiddens' . EXT, 'post_types' => include 'settings/post_types' . EXT, 'taxonomies' => include 'settings/taxonomies' . EXT), 'processor' => array('preupdate' => array(), 'postupdate' => array('save_settings')), 'cleanup' => array('switch' => array('switch_not_available')), 'checks' => array('counter' => array('is_numeric', 'not_empty')), 'errors' => array('not_empty' => __('Invalid Value.', pixtypes::textdomain())), 'callbacks' => array('save_settings' => 'save_pixtypes_settings'), 'display_settings' => $display_settings, 'debug' => $debug);
# config
예제 #9
0
파일: admin.php 프로젝트: pwzCypher/wp-push
		<?php 
    if ($processor->performed_update()) {
        ?>
			<br/>
			<p class="update-nag">
				<?php 
        _e('Settings have been updated.', 'pixtypes_txtd');
        ?>
			</p>
		<?php 
    }
    ?>

		<?php 
    echo $f = pixtypes::form($config, $processor);
    echo $f->field('hiddens')->render();
    ?>

			<?php 
    echo $f->field('post_types')->render();
    ?>

			<?php 
    echo $f->field('taxonomies')->render();
    ?>

			<button type="submit" class="button button-primary">
				<?php 
    _e('Save Changes', 'pixtypes_txtd');
    ?>
예제 #10
0
    define('EXT', '.php');
}
require 'core/bootstrap' . EXT;
$config = (include 'plugin-config' . EXT);
include 'features/class-pix-query' . EXT;
// set textdomain
pixtypes::settextdomain($config['textdomain']);
// Ensure Test Data
// ----------------
$defaults = (include 'plugin-defaults' . EXT);
$current_data = get_option($config['settings-key']);
if ($current_data === false) {
    add_option($config['settings-key'], $defaults);
} else {
    if (count(array_diff_key($defaults, $current_data)) != 0) {
        $plugindata = array_merge($defaults, $current_data);
        update_option($config['settings-key'], $plugindata);
    }
}
# else: data is available; do nothing
// Load Callbacks
// --------------
$basepath = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$callbackpath = $basepath . 'callbacks' . DIRECTORY_SEPARATOR;
pixtypes::require_all($callbackpath);
require_once plugin_dir_path(__FILE__) . 'class-pixtypes.php';
// Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
register_activation_hook(__FILE__, array('PixTypesPlugin', 'activate'));
//register_deactivation_hook( __FILE__, array( 'PixTypesPlugin', 'deactivate' ) );
global $pixtypes_plugin;
$pixtypes_plugin = PixTypesPlugin::get_instance();