function create($args = array()) { $args = wp_parse_args($args, $this->default_fields()); $key = $args['key'] ? $args['key'] : pl_create_id($args['name']); if (isset($this->objects[$key])) { $key = $key . '_' . pl_new_clone_id(); } $new = array($key => $args); // turns out you can add arrays, puts new templates at front $this->objects = $new + $this->objects; $this->update_objects(); return $key; }
/** * Add pages to main settings area. * * @since 2.2 * * @param $args Array as input. * @param string $name Name of page. * @param string $title Title of page. * @param string $path Function use to get page contents. * @param array $array Array containing page page of settings. * @param string $type Type of page. * @param string $raw Send raw HTML straight to the page. * @param string $layout Layout type. * @param string $icon URI for page icon. * @param int $postion Position to insert into main menu. * @return array $optionarray */ function pl_add_options_page($args) { if (pl_has_editor()) { global $pagelines_add_settings_panel; $d = array('name' => 'No Name', 'icon' => 'icon-edit', 'pos' => 10, 'opts' => array()); if (!isset($args['opts']) && isset($args['array'])) { $args['opts'] = $args['array']; } if (!isset($args['pos']) && isset($args['position'])) { $args['pos'] = $args['position']; } $a = wp_parse_args($args, $d); $id = pl_create_id($a['name']); // make sure its not set elsewhere. Navbar was already set, and we were writing twice if (!isset($pagelines_add_settings_panel[$id])) { $pagelines_add_settings_panel[$id] = $a; } } }