Skip to content

Commit

Permalink
Option added in gd_categories widget/shortcode to CPT title - ADDED
Browse files Browse the repository at this point in the history
  • Loading branch information
kprajapatii committed Aug 23, 2019
1 parent 255784b commit 21b200d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
1 change: 1 addition & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Fail to save feature image for new listing when post revision is enabled - FIXED
* Post link not working in email sent to admin on post edit - FIXED
* Post badge does not supports category and tags - FIXED
* Option added in gd_categories widget/shortcode to CPT title - ADDED

= 2.0.0.66 =
* GD post favourites widget issue for icon option - FIXED
Expand Down
20 changes: 20 additions & 0 deletions includes/class-geodir-maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ public static function get_categories_filter( $post_type, $cat_parent = 0, $hide
$term_args['exclude'] = $exclude;
}

/**
* Filter terms order by field.
*
* @since 2.0.0.67
*/
$orderby = apply_filters( 'geodir_map_categories_orderby', '', $post_type, $cat_parent, $hierarchical );
if ( ! empty( $orderby ) ) {
$term_args['orderby'] = $orderby;
}

/**
* Filter terms in ascending or descending order.
*
* @since 2.0.0.67
*/
$order = apply_filters( 'geodir_map_categories_order', '', $post_type, $cat_parent, $hierarchical );
if ( ! empty( $order ) ) {
$term_args['order'] = $order;
}

$cat_terms = get_terms( $term_args );

if ($hide_empty && ! $hierarchical) {
Expand Down
50 changes: 28 additions & 22 deletions includes/widgets/class-geodir-widget-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ public function __construct() {
'desc_tip' => true,
'advanced' => false
),
'post_type' => array(
'title' => __('Post Type:', 'geodirectory'),
'desc' => __('The custom post types to show by default. Only used when there are multiple CPTs.', 'geodirectory'),
'type' => 'select',
'options' => $this->post_type_options(),
'default' => '0',
'desc_tip' => true,
'advanced' => true
),
'cpt_title' => array(
'title' => __( 'Show CPT title:', 'geodirectory' ),
'desc' => __( 'Tick to show CPT title. Ex: Place Categories', 'geodirectory' ),
'type' => 'checkbox',
'desc_tip' => true,
'value' => '1',
'default' => 0,
'advanced' => true
),
'title_tag' => array(
'title' => __('Title tag:', 'geodirectory'),
'desc' => __('The tag used to display the auto generated CPT title.', 'geodirectory'),
Expand All @@ -57,20 +75,11 @@ public function __construct() {
'h4' => 'h4',
'h3' => 'h3',
'h2' => 'h2',
'hide' => 'hide',
'span' => 'span',
),
'default' => 'h4',
'desc_tip' => true,
'advanced' => true
),
'post_type' => array(
'title' => __('Post Type:', 'geodirectory'),
'desc' => __('The custom post types to show by default. Only used when there are multiple CPTs.', 'geodirectory'),
'type' => 'select',
'options' => $this->post_type_options(),
'default' => '0',
'desc_tip' => true,
'advanced' => true
),
'cpt_ajax' => array(
'title' => __('Add CPT ajax select:', 'geodirectory'),
Expand Down Expand Up @@ -211,6 +220,7 @@ public function output($args = array(), $widget_args = array(),$content = ''){
'use_image' => '0',
'cpt_ajax' => '0',
'title_tag' => 'h4',
'cpt_title' => ''
);

/**
Expand Down Expand Up @@ -349,6 +359,7 @@ public static function categories_output($params) {
'no_cpt_filter' => '',
'no_cat_filter' => '',
'cpt_ajax' => '',
'cpt_title' => '',
)
);

Expand Down Expand Up @@ -478,7 +489,7 @@ public static function categories_output($params) {
if ($ajax_cpt && $ajax_cpt !== $cpt) {
continue;
}
$cpt_options[] = '<option value="' . $cpt . '" ' . selected( $cpt, $current_posttype, false ) . '>' . wp_sprintf( __( '%s Categories', 'geodirectory' ), $cpt_info['labels']['singular_name'] ) . '</option>';
$cpt_options[] = '<option value="' . $cpt . '" ' . selected( $cpt, $current_posttype, false ) . '>' . wp_sprintf( __( '%s Categories', 'geodirectory' ), __( $cpt_info['labels']['singular_name'], 'geodirectory' ) ) . '</option>';

// if ajaxed then only show the first one
if($cpt_ajax && $cpt_list != ''){ continue;}
Expand Down Expand Up @@ -514,18 +525,11 @@ public static function categories_output($params) {
$row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing';
}
$cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left_class.'">';

if ( ! empty( $args['cpt_title'] ) && ! $cpt_ajax ) {
$cpt_row .= '<' . esc_attr( $args['title_tag'] ) . ' class="gd-cptcat-title">' . wp_sprintf( __( '%s Categories', 'geodirectory' ), __( $cpt_info['labels']['singular_name'], 'geodirectory' ) ) . '</' . esc_attr( $args['title_tag'] ) . '>';
}

// if ($is_category && $cat_filter && $cpt == $current_posttype) {
// $term_info = get_term($current_term_id, $cat_taxonomy);
//
// $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : '';
// $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
//
// $count = !$hide_count ? ' <span class="gd-cptcat-count">' . $term_info->count . '</span>' : '';
// if($args['title_tag'] !="hide") $cpt_row .= '<'.$args['title_tag'].' class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</'.$args['title_tag'].'>';
// } else {
// if($args['title_tag'] !="hide") $cpt_row .= '<'.$args['title_tag'].' class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</'.$args['title_tag'].'>';
// }
foreach ($categories as $category) {
$term_icon = '';
$cat_color ='';
Expand Down Expand Up @@ -580,6 +584,8 @@ public static function categories_output($params) {
$output .= '<div class="gd-cptcats-select"><div class="gd-wgt-params">';
$output .= '<input type="hidden" name="post_type" value="' . esc_attr( $post_type ) . '">';
$output .= '<input type="hidden" name="cpt_ajax" value="' . $cpt_ajax . '">';
$output .= '<input type="hidden" name="cpt_title" value="' . absint( $args['cpt_title'] ) . '">';
$output .= '<input type="hidden" name="title_tag" value="' . $args['title_tag'] . '">';
$output .= '<input type="hidden" name="hide_empty" value="' . $hide_empty . '">';
$output .= '<input type="hidden" name="hide_count" value="' . $hide_count . '">';
$output .= '<input type="hidden" name="hide_icon" value="' . $hide_icon . '">';
Expand Down

0 comments on commit 21b200d

Please sign in to comment.