'name');
private $taxonomy_name, $label_name;
private $post_types = array('post', 'pages'),
$singular_name = null,
$show_admin_col = false;
public function set_label_name($label_name) {
$this->label_name = $label_name;
return $this;
}
public function set_show_admin_col($show_admin_col) {
$this->show_admin_col = $show_admin_col;
return $this;
}
public function set_singular_name($singular_name) {
$this->singular_name = $singular_name;
return $this;
}
public function get_hierarchical() {
return $this->hierarchical;
}
public function set_hierarchical($hierarchical) {
$this->hierarchical = $hierarchical;
return $this;
}
public function get_show_ui() {
return $this->show_ui;
return $this;
}
public function set_show_ui($show_ui) {
$this->show_ui = $show_ui;
}
public function get_query_var() {
return $this->query_var;
}
public function set_query_var($query_var) {
$this->query_var = $query_var;
return $this;
}
public function get_show_tagcloud() {
return $this->show_tagcloud;
}
public function set_show_tagcloud($show_tagcloud) {
$this->show_tagcloud = $show_tagcloud;
return $this;
}
public function get_show_in_nav_menus() {
return $this->show_in_nav_menus;
}
public function set_show_in_nav_menus($show_in_nav_menus) {
$this->show_in_nav_menus = $show_in_nav_menus;
return $this;
}
public function get_rewrite() {
return $this->rewrite;
}
public function set_rewrite($rewrite) {
$this->rewrite = $rewrite;
return $this;
}
public function get_taxonomy_name() {
return $this->taxonomy_name;
}
public function set_taxonomy_name($taxonomy_name) {
$this->taxonomy_name = $taxonomy_name;
return $this;
}
public function get_post_types() {
return $this->post_types;
}
public function set_post_types($post_types) {
$this->post_types = $post_types;
return $this;
}
public function get_label_name() {
return $this->label_name;
}
/**
*
* @param type $taxonomy_name
* @param type $label_name
*/
function __construct($taxonomy_name, $label_name = null) {
$this->taxonomy_name = $taxonomy_name;
$this->label_name = $label_name;
}
/**
* register category style taxonomies
*/
public function register() {
// Add new taxonomy, make it hierarchical (like categories)
$name = ucfirst($this->get_taxonomy_name());
$label = (isset($this->label_name) ? $this->label_name : $this->taxonomy_name);
$singular = (isset($this->singular_name) ? $this->singular_name : $this->taxonomy_name);
$labels = array(
'name' => _x($label, 'taxonomy general name'),
'singular_name' => _x($singular, 'taxonomy singular name'),
'search_items' => __('Search ' . $name),
'all_items' => __('All ' . $label),
'parent_item' => __('Parent ' . $singular),
'parent_item_colon' => __('Parent ' . $label . ':'),
'edit_item' => __('Edit ' . $singular),
'update_item' => __('Update ' . $singular),
'add_new_item' => __('Add New ' . $singular),
'new_item_name' => __('New ' . $singular),
'menu_name' => __($label),
);
register_taxonomy($this->get_taxonomy_name(), $this->get_post_types(), array(
'hierarchical' => $this->hierarchical,
'labels' => $labels,
'show_ui' => $this->get_show_ui(),
'query_var' => $this->get_query_var(),
'rewrite' => array('slug' => $this->get_taxonomy_name()),
'show_tagcloud' => $this->get_show_tagcloud(),
'show_in_nav_menus' => $this->get_show_in_nav_menus(),
'show_admin_column' => true,
));
}
public function tags() {
$this->set_hierarchical(false);
$this->register();
}
public function init() {
add_action('init', array(&$this, 'register'), 0);
}
}
/**
* @package WordPress
* @subpackage Core-WP
* @author shawnsandy
*/
/**
*
*/
/**
* A simple form generation class for WordPress
*
* $f_text['Sample Text'] = array(
* 'desc' => 'A sample Text field',
* 'field' => $c_form->setText(array('name'=>'sample-text','type'=>'text')));
* $f_text['Sample Textarea'] = array(
* 'desc' => 'A sample Textarea field',
* 'field' => $c_form->setTextarea(array('name'=>'sample-text','value'=>'Textarea Value'))); *
* $c_form->render($f_text,'form_name');
*
*/
class cwp_form {
//put your code here
private $text = array();
private $button = array();
private $textarea = array();
private $checkbox = array();
private $list = array();
private $radio = array();
private $captacha = null;
private $action;
private $method,
$form_name,
$button_label;
public function __construct($form_name = 'cwp_form', $action = "", $method = "post") {
$this->form_name = $form_name;
$this->action = $action;
$this->method = $method;
}
public function get_button_label() {
return $this->button_label;
}
public function set_button_label($button_label) {
$this->button_label = $button_label;
return $this;
}
public function get_form_name() {
return $this->form_name;
}
/**
* Factory pattern
* @param type $form_name
* @param type $action
* @param string $method
* @return \cwp_form
*/
public static function load($form_name, $action, $method = "post") {
return new cwp_form($form_name, $action = "{$action}", $method = "post");
}
public function getCaptacha() {
return $this->captacha;
}
public function getText() {
return $this->text;
}
public function getButton() {
return $this->button;
}
public function getTextarea() {
return $this->textarea;
}
public function getCheckbox() {
return $this->checkbox;
}
public function getList() {
return $this->list;
}
public function getRadio() {
return $this->radio;
}
public function getAction() {
return $this->action;
}
public function setAction($action) {
$this->action = $action;
return $this;
}
public function setCaptacha($captacha) {
$this->captacha = $captacha;
return $this;
}
/**
*
* @param array $array - type,name,value,placeholder,required,pattern,min,max
* @return type
*/
public function setText($array = array()) {
$required = (isset($array['required']) ? 'required' : null);
$pattern = (isset($array['pattern']) ? "pattern=\"{$array['pattern']}\"" : null);
$min = (isset($array['min']) ? "min=\"{$array['min']}\"" : null);
$max = (isset($array['max']) ? "min=\"{$array['max']}\"" : null);
$this->text = "";
return $this->text;
}
/* * ---------------------text feilds -----------------------------* */
/**
*
* @param type $name
* @param type $value
* @param type $placeholder
* @param type $required
* @param type $pattern
* @return type
*/
public function text_input($name, $value = '', $placeholder = '', $required = null, $pattern = null) {
$array['type'] = "text";
$array['name'] = $name;
$array['value'] = $value;
$array['placeholder'] = $placeholder;
$array['required'] = $required;
$array['pattern'] = $pattern;
return $this->setText($array);
}
public function email_input($name, $value = '', $placeholder = 'Your Email Address', $required = true, $pattern = null) {
$array['type'] = "email";
$array['name'] = $name;
$array['value'] = $value;
$array['placeholder'] = $placeholder;
$array['required'] = $required;
$array['pattern'] = $pattern;
return $this->setText($array);
}
public function tel_input($name, $value = '', $placeholder = 'Telphone Number 000-000-0000', $required = false, $pattern = null) {
$array['type'] = "tel";
$array['name'] = $name;
$array['value'] = $value;
$array['pattern'] = "\d{10}";
$array['placeholder'] = $placeholder;
$array['required'] = $required;
return $this->setText($array);
}
public function url_input($name, $value = '', $placeholder = '(http:// yoururl.com)', $required = null) {
$array['type'] = "url";
$array['name'] = $name;
$array['value'] = $value;
$array['placeholder'] = $placeholder;
$array['required'] = $required;
return $this->setText($array);
}
public function hidden_input($name, $value = '') {
$array['type'] = "hidden";
$array['name'] = $name;
$array['value'] = $value;
return $this->setText($array);
}
/**
* **************************buttons****************************************
*/
/**
*
* @param type $button
* @return type
*/
public function setButton($button = array()) {
$this->button = "";
return $this->button;
}
/**
* **************************textarea***************************************
*/
/**
*
* @param type $textarea
* @return type
*/
public function setTextarea($array = array()) {
$required = (isset($array['required'])) ? 'required' : null;
$pattern = (isset($array['pattern']) ? "pattern=\"{$array['pattern']}\"" : null);
$this->textarea = "";
return $this->textarea;
}
/**
*
* @param type $name
* @param type $value
* @param type $required
* @param type $placeholder
* @return type
*/
public function textarea($name, $value = '', $required = null, $placeholder = '', $max = 150) {
$arr['name'] = $name;
$arr['value'] = $value;
$arr['required'] = $required;
$arr['placeholder'] = $placeholder;
$arr['maxlength'] = $max;
return $this->setTextarea($arr);
}
public function setCheckbox($checkbox = array()) {
$this->checkbox = "";
return $this->checkbox;
}
public function setList($list = array()) {
$this->list = "";
return $this->list;
}
public function setRadio($radio = array()) {
$this->radio = $radio;
return $this->radio;
}
/**
* *********************Erros**********************************************
*/
public function form_error($error = array()) {
if (is_array($error) AND !empty($error)) {
$er[] = "
* //set menu depth and the menu location to primary
* set_depth(1)->menu('primary'); ?>
* menu('browse'); ?>
*
*/
public static function factory() {
return new cwp_navs();
}
/**
*
* cwp_navs::factory()->set_depth(0)->tbs_menu('primary');
*
* @param type $theme_location
* @return \cwp_navs
*/
public function menu($theme_location = 'primary') {
$this->theme_location = $theme_location;
wp_nav_menu(array(
'theme_location' => $this->theme_location,
'fallback_cb' => $this->fallback_cb,
'container' => $this->container,
'container_class' => $this->container_class,
'menu_class' => $this->menu_class,
'echo' => $this->echo,
'before' => $this->before,
'after' => $this->after,
'link_before' => $this->link_before,
'link_after' => $this->link_after,
'depth' => $this->depth,
'walker' => $this->walker
));
return $this;
}
/**
*
* cwp_navs::factory()->set_depth(0)->tbs_menu('primary');
*
* @param type $theme_location
* @return \cwp_navs
*/
public function tbs_menu($theme_location = 'primary') {
$this->theme_location = $theme_location;
$this->menu_class = 'nav';
wp_nav_menu(array(
'theme_location' => $this->theme_location,
'fallback_cb' => $this->fallback_cb,
'container' => $this->container,
'container_class' => $this->container_class,
'menu_class' => 'nav',
'echo' => $this->echo,
'before' => $this->before,
'after' => $this->after,
'link_before' => $this->link_before,
'link_after' => $this->link_after,
'depth' => $this->depth,
'walker' => $this->walker
));
return $this;
}
public function menu_description($location) {
//$this->theme_location = $location;
//$this->theme_location = $location;
$this->walker = new nav_descriptions();
return $this->menu($location);
}
public function default_menu() {
?>
theme_location == $location):
$items .= '
* add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
$items = cwp_navs::factory()->add_drop_down($items, $args,'browse',"Another Dropwdown");
return $items;
}
*
* @param type $items
* @param type $args
* @param type $location
* @param type $name
* @param type $content
* @param type $class
* @return string
*/
public function add_drop_down($items, $args, $location, $name = "Drop Down", $content = 'Some Content', $class = 'ui box medium') {
if ($args->theme_location == $location):
$items .="
* add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
$items = cwp_navs::factory()->add_loginout($items,$args,'primary');
return $items;
}
*
* @param type $items
* @param type $args
* @param type $location
* @return string
*/
public function add_loginout($items, $args, $location) {
if (is_user_logged_in() && $args->theme_location == $location) {
$items .= ' 'cwp_articles')); ?>
*/
public static function loop($query = null, $tpl_slug = null, $tpl_name = null) {
global $post;
if (isset($query))
query_posts($query);
if (have_posts()):
while (have_posts()):
the_post();
$post_type = get_post_type();
$post_format = (get_post_format() ? get_post_format() : 'general');
if ($tpl_slug == 'post_type'):
$tpl_slug = $post_type;
endif;
if ($tpl_name == 'format')
$tpl_name = $post_format;
$slug = isset($tpl_slug) ? $tpl_slug : 'base';
$name = isset($tpl_name) ? $tpl_name : 'general';
cwp_layout::tpl_part($slug, $name);
endwhile;
else :
cwp_layout::tpl_part(null, 'no_post');
endif;
wp_reset_query();
}
/**
*
* Uses WP_Query to create post loops
* @param string / array $query
* @param string $tpl_slug // default - base
* @param string $tpl_name // default - general
* @param string $def_tpl
*
*/
public static function query($query = 'showposts=5', $tpl_slug = null, $tpl_name = null, $def_tpl = 'no_post') {
global $post;
$wp = new WP_Query();
$wp->query($query);
if ($wp->have_posts()):
while ($wp->have_posts()):
$wp->the_post();
$post_type = get_post_type();
$post_format = (get_post_format() ? get_post_format() : 'general');
if ($tpl_slug == 'post_type')
$tpl_slug = $post_type;
if ($tpl_slug == 'format')
$tpl_slug = $post_format;
$slug = isset($tpl_slug) ? $tpl_slug : 'base';
$name = isset($tpl_name) ? $tpl_name : 'general';
cwp_layout::tpl_part($slug, $name);
endwhile;
else :
cwp_layout::tpl_part(null, $def_tpl);
endif;
wp_reset_postdata();
}
}
class cwp_post_gallery {
public function __construct($post_parent) {
$this->post_parent = $post_parent;
}
public static function factory($post_parent) {
return $factory = new cwp_post_gallery($post_parent);
}
private $number_post = -1,
$order = 'ASC',
$post_parent = null,
$image_size = 'thumbnail';
public function set_image_size($image_size) {
$this->image_size = $image_size;
return $this;
}
public function set_number_post($number_post) {
$this->number_post = $number_post;
return $this;
}
public function set_order($order) {
$this->order = $order;
return $this;
}
public function set_post_parent($parent) {
$this->post_parent = $parent;
return $this;
}
public function display($items_class='span3',$container_class='row') {
global $post;
$argsThumb = array(
'showposts' => $this->number_post,
'order' => $this->order,
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null,
//'exclude' => get_post_thumbnail_id($post->ID)
);
$attachments = get_posts($argsThumb);
if ($attachments) {
echo '