public function __construct() { $self = new \ReflectionClass($this); $public_methods = $self->getMethods(\ReflectionMethod::IS_PUBLIC); if (empty($public_methods)) { return; } foreach ($public_methods as $method) { if ($method->name != '__construct') { // Parse string $signature = new GString($method->name); // Convert CamelCase to forward slash syntax and double underscore to a dash in // for bbPress. Also support and accomodate incompatible action names i.e. load-index.php // post-new.php in CPT, ACF, etc. $signature = $signature->replaceAll('([A-Z])', '/$0')->replace('__', '-')->replace('load_index_php', 'load-index.php')->replace('_php', '.php'); // Optimized for speed, handle acf only if present if (strpos($method->name, 'acf_') !== false) { $signature = $signature->replace('acf_helpers_', 'acf/helpers/')->replace('acf_location_rule_types', 'acf/location/rule_types')->replace('acf_location_rule_values_', 'acf/location/rule_values/')->replace('acf_options_page_', 'acf/options_page/')->replace('acf_input_', 'acf/input/')->replace('acf_', 'acf/'); } $name = (string) $signature->toLowerCase(); $params = $method->getNumberOfParameters(); // Check for activation, deactivation, uninstall hooks if ($name == 'activation') { register_activation_hook(__FILE__, array($this, $method->name)); } elseif ($name == 'deactivation') { register_deactivation_hook(__FILE__, array($this, $method->name)); } elseif ($name == 'uninstall') { register_uninstall_hook(__FILE__, array($this, $method->name)); // Look for shortcode definition } elseif ($signature->getLeftMost('_')->equals('shortcode')) { $signature = new GString($name); add_shortcode((string) $signature->delLeftMost('_'), array($this, $method->name)); // Assume for action/filter hook definition } else { // Check for priority option $priority = (string) $signature->getRightMost('_'); if (is_numeric($priority)) { $priority = (int) $priority; $signature = new GString($name); $name = (string) $signature->delRightMost('_'); } else { $priority = 10; } add_filter($name, array($this, $method->name), $priority, $params); } } } }
/** * Predisplay function * * @return void */ function prepare() { $s = new GSegment(); $s->setCoordinates(0, $this->_height, $this->_width, $this->_height); $s->setColor($this->_grid_r_color, $this->_grid_g_color, $this->_grid_b_color); $this->addElement($s); $s = new GSegment(); $s->setCoordinates(0, $this->_height / 2, $this->_width, $this->_height / 2); $s->setColor($this->_grid_r_color, $this->_grid_g_color, $this->_grid_b_color); $this->addElement($s); $s = new GSegment(); $s->setCoordinates(0, 0, $this->_width, 0); $s->setColor($this->_grid_r_color, $this->_grid_g_color, $this->_grid_b_color); $this->addElement($s); $count = count($this->_legend); $div = $this->_width / ($count - 1); for ($i = 0; $i < $count - 1; $i = $i + (int) ($count / 5)) { $s = new GSegment(); $s->setCoordinates($i * $div, 0, $i * $div, $this->_height); $s->setColor($this->_grid_r_color, $this->_grid_g_color, $this->_grid_b_color); $this->addElement($s); $str = new GString($this->_legend[$i]); $str->setCoordinates($i * $div, $this->_height); $str->setXDistance(10); $str->setYDistance(-5); $this->addElement($str); } $s = new GSegment(); $s->setCoordinates(($count - 1) * $div, 0, ($count - 1) * $div, $this->_height); $s->setColor($this->_grid_r_color, $this->_grid_g_color, $this->_grid_b_color); $this->addElement($s); $str = new GString($this->_legend[$count - 1]); $str->setCoordinates(($count - 1) * $div, $this->_height); $str->setXDistance(10); $str->setYDistance(-5); $this->addElement($str); $str = new GString("" . $this->_max_value); $str->setCoordinates(0, 0); $str->setDistance(15); $this->addElement($str); }
/** * Provide persistent menu icon and set default screen layout. */ function admin_head_1() { global $wp_post_types; $css = ''; foreach ($wp_post_types as $post_type => $args) { if (strpos($args->menu_icon_font, '\\e') !== false) { $menu = new GString($args->menu_icon_font); $font = (string) $menu->getLeftMost(' '); $char = (string) $menu->delLeftMost(' '); $css .= "a.menu-icon-" . $post_type; $css .= " div.wp-menu-image:before { font: 400 20px/1 " . $font; $css .= " !important; content: '" . $char . "'; }\n"; } // Set the default screen layout (1 or 2 columns) for the current user. if (get_user_meta(get_current_user_id(), 'screen_layout_' . $post_type, true) === '') { update_user_meta(get_current_user_id(), 'screen_layout_' . $post_type, $args->default_screen_layout); } } if ($css !== '') { echo "<style type=\"text/css\">\n" . $css . "</style>\n"; } }
/** * Predisplay function * * @return void */ function prepare() { $values = $this->_values; $count = count($values); $max = max(max($values), 10); $min = min($values); $normalized = array(); for ($i = 0; $i < $count; $i++) { $normalized[$i] = $this->_height - $values[$i] / $max * $this->_height; } $div = $this->_width / ($count - 1); if ($this->getDotSize() > 0) { for ($i = 0; $i < $count; $i++) { $p = new GCircledPoint(); $p->setBackgroundColor($this->_background_r_color, $this->_background_g_color, $this->_background_b_color); $p->setCoordinates($i * $div, $normalized[$i]); $p->setColor($this->_r_color, $this->_g_color, $this->_b_color); $p->setSize($this->getDotSize()); $this->addElement($p); if ($this->_print) { $s = new GString("{$values[$i]}"); $s->setDistance(18); $s->setCoordinates($i * $div, $normalized[$i]); $this->addElement($s); } } } }
/** * Predisplay function * * @return void */ function prepare() { $values = $this->_values; $count = count($values); $max = max(max($values), 10); $min = min($values); $normalized = array(); for ($i = 0; $i < $count; $i++) { if ($max == 0) { $normalized[$i] = $this->_height; } else { $normalized[$i] = $this->_height - $values[$i] / $max * $this->_height; } } $div = $this->_width / ($count - 1); for ($i = 0; $i < $count - 1; $i++) { $s = new GSegment(); $s->setCoordinates($i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1]); $s->setSize($this->getSize()); $s->setColor($this->_r_color, $this->_g_color, $this->_b_color); $this->addElement($s); if ($this->_show_background) { $values = array($i * $div, $this->_height, $i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1], ($i + 1) * $div, $this->_height); $p = new GPolygon($values); $p->setColor($this->_background_r_color, $this->_background_g_color, $this->_background_b_color); $this->addElement($p); } if ($this->_show_values && $i % 3 == 0) { $str = new GString("" . $this->_values[$i]); $str->setCoordinates($i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1]); $str->setDistance(18); $this->addElement($str); } } $str = new GString("" . $this->_values[$count - 1]); $str->setCoordinates(($count - 1) * $div, $normalized[$count - 1]); $str->setDistance(18); $this->addElement($str); }