Skip to content

Commit

Permalink
Merge pull request #406 from kprajapatii/master
Browse files Browse the repository at this point in the history
cpt v2 changes
  • Loading branch information
Stiofan authored Aug 9, 2018
2 parents 560142b + 72818fa commit e19b8d0
Show file tree
Hide file tree
Showing 15 changed files with 389 additions and 36 deletions.
3 changes: 3 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ function geodirSelect2TemplateSelection($el, data, main) {
rEl += data.text;
rEl += '</span>';
return jQuery(rEl);
}
if ($el.data('dashicons') && $option.data('dashicon')) {
return jQuery('<span class="select2-selection_gd_dashicon"><span class="dashicons ' + $option.data('dashicon') + '"></span><span class="gd-dashicon-text"> ' + data.text + '</span></span>');
}
return data.text;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/admin.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/geodirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ function geodir_resize_rating_stars(re) {
}

function geodir_load_search_form(stype, el) {
var $adv_show = jQuery(el).closest('.geodir_advance_search_widget').attr('data-show-adv');
var $adv_show = jQuery(el).closest('.geodir-search-container').attr('data-show-adv');

jQuery.ajax({
url: geodir_params.ajax_url,
Expand All @@ -693,7 +693,7 @@ function geodir_load_search_form(stype, el) {
},
success: function(data, textStatus, xhr) {
// replace whole form
jQuery(el).closest('.geodir_advance_search_widget').html(data);
jQuery(el).closest('.geodir-search-container').html(data);

geodir_setup_search_form();
// trigger a custom event wen setting up the search form so we can hook to it from addons
Expand Down
2 changes: 1 addition & 1 deletion assets/js/geodirectory.min.js

Large diffs are not rendered by default.

242 changes: 241 additions & 1 deletion includes/admin/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,244 @@ function geodir_admin_body_class_active_map($class = '') {

return $class;
}
add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100);
add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100);

function geodir_dashicon_options() {
$dashicons = array(
'dashicons-admin-appearance' => 'f100',
'dashicons-admin-collapse' => 'f148',
'dashicons-admin-comments' => 'f101',
'dashicons-admin-customizer' => 'f540',
'dashicons-admin-generic' => 'f111',
'dashicons-admin-home' => 'f102',
'dashicons-admin-links' => 'f103',
'dashicons-admin-media' => 'f104',
'dashicons-admin-multisite' => 'f541',
'dashicons-admin-network' => 'f112',
'dashicons-admin-page' => 'f105',
'dashicons-admin-plugins' => 'f106',
'dashicons-admin-post' => 'f109',
'dashicons-admin-settings' => 'f108',
'dashicons-admin-site' => 'f319',
'dashicons-admin-tools' => 'f107',
'dashicons-admin-users' => 'f110',
'dashicons-album' => 'f514',
'dashicons-align-center' => 'f134',
'dashicons-align-left' => 'f135',
'dashicons-align-none' => 'f138',
'dashicons-align-right' => 'f136',
'dashicons-analytics' => 'f183',
'dashicons-archive' => 'f480',
'dashicons-arrow-down' => 'f140',
'dashicons-arrow-down-alt' => 'f346',
'dashicons-arrow-down-alt2' => 'f347',
'dashicons-arrow-left' => 'f141',
'dashicons-arrow-left-alt' => 'f340',
'dashicons-arrow-left-alt2' => 'f341',
'dashicons-arrow-right' => 'f139',
'dashicons-arrow-right-alt' => 'f344',
'dashicons-arrow-right-alt2' => 'f345',
'dashicons-arrow-up' => 'f142',
'dashicons-arrow-up-alt' => 'f342',
'dashicons-arrow-up-alt2' => 'f343',
'dashicons-art' => 'f309',
'dashicons-awards' => 'f313',
'dashicons-backup' => 'f321',
'dashicons-book' => 'f330',
'dashicons-book-alt' => 'f331',
'dashicons-building' => 'f512',
'dashicons-businessman' => 'f338',
'dashicons-calendar' => 'f145',
'dashicons-calendar-alt' => 'f508',
'dashicons-camera' => 'f306',
'dashicons-carrot' => 'f511',
'dashicons-cart' => 'f174',
'dashicons-category' => 'f318',
'dashicons-chart-area' => 'f239',
'dashicons-chart-bar' => 'f185',
'dashicons-chart-line' => 'f238',
'dashicons-chart-pie' => 'f184',
'dashicons-clipboard' => 'f481',
'dashicons-clock' => 'f469',
'dashicons-cloud' => 'f176',
'dashicons-controls-back' => 'f518',
'dashicons-controls-forward' => 'f519',
'dashicons-controls-pause' => 'f523',
'dashicons-controls-play' => 'f522',
'dashicons-controls-repeat' => 'f515',
'dashicons-controls-skipback' => 'f516',
'dashicons-controls-skipforward' => 'f517',
'dashicons-controls-volumeoff' => 'f520',
'dashicons-controls-volumeon' => 'f521',
'dashicons-dashboard' => 'f226',
'dashicons-desktop' => 'f472',
'dashicons-dismiss' => 'f153',
'dashicons-download' => 'f316',
'dashicons-edit' => 'f464',
'dashicons-editor-aligncenter' => 'f207',
'dashicons-editor-alignleft' => 'f206',
'dashicons-editor-alignright' => 'f208',
'dashicons-editor-bold' => 'f200',
'dashicons-editor-break' => 'f474',
'dashicons-editor-code' => 'f475',
'dashicons-editor-contract' => 'f506',
'dashicons-editor-customchar' => 'f220',
'dashicons-editor-expand' => 'f211',
'dashicons-editor-help' => 'f223',
'dashicons-editor-indent' => 'f222',
'dashicons-editor-insertmore' => 'f209',
'dashicons-editor-italic' => 'f201',
'dashicons-editor-justify' => 'f214',
'dashicons-editor-kitchensink' => 'f212',
'dashicons-editor-ol' => 'f204',
'dashicons-editor-outdent' => 'f221',
'dashicons-editor-paragraph' => 'f476',
'dashicons-editor-paste-text' => 'f217',
'dashicons-editor-paste-word' => 'f216',
'dashicons-editor-quote' => 'f205',
'dashicons-editor-removeformatting' => 'f218',
'dashicons-editor-rtl' => 'f320',
'dashicons-editor-spellcheck' => 'f210',
'dashicons-editor-strikethrough' => 'f224',
'dashicons-editor-table' => 'f535',
'dashicons-editor-textcolor' => 'f215',
'dashicons-editor-ul' => 'f203',
'dashicons-editor-underline' => 'f213',
'dashicons-editor-unlink' => 'f225',
'dashicons-editor-video' => 'f219',
'dashicons-email' => 'f465',
'dashicons-email-alt' => 'f466',
'dashicons-exerpt-view' => 'f164',
'dashicons-external' => 'f504',
'dashicons-facebook' => 'f304',
'dashicons-facebook-alt' => 'f305',
'dashicons-feedback' => 'f175',
'dashicons-filter' => 'f536',
'dashicons-flag' => 'f227',
'dashicons-format-aside' => 'f123',
'dashicons-format-audio' => 'f127',
'dashicons-format-chat' => 'f125',
'dashicons-format-gallery' => 'f161',
'dashicons-format-image' => 'f128',
'dashicons-format-quote' => 'f122',
'dashicons-format-status' => 'f130',
'dashicons-format-video' => 'f126',
'dashicons-forms' => 'f314',
'dashicons-googleplus' => 'f462',
'dashicons-grid-view' => 'f509',
'dashicons-groups' => 'f307',
'dashicons-hammer' => 'f308',
'dashicons-heart' => 'f487',
'dashicons-hidden' => 'f530',
'dashicons-id' => 'f336',
'dashicons-id-alt' => 'f337',
'dashicons-image-crop' => 'f165',
'dashicons-image-filter' => 'f533',
'dashicons-image-flip-horizontal' => 'f169',
'dashicons-image-flip-vertical' => 'f168',
'dashicons-image-rotate' => 'f531',
'dashicons-image-rotate-left' => 'f166',
'dashicons-image-rotate-right' => 'f167',
'dashicons-images-alt' => 'f232',
'dashicons-images-alt2' => 'f233',
'dashicons-index-card' => 'f510',
'dashicons-info' => 'f348',
'dashicons-laptop' => 'f547',
'dashicons-layout' => 'f538',
'dashicons-leftright' => 'f229',
'dashicons-lightbulb' => 'f339',
'dashicons-list-view' => 'f163',
'dashicons-location' => 'f230',
'dashicons-location-alt' => 'f231',
'dashicons-lock' => 'f160',
'dashicons-marker' => 'f159',
'dashicons-media-archive' => 'f501',
'dashicons-media-audio' => 'f500',
'dashicons-media-code' => 'f499',
'dashicons-media-default' => 'f498',
'dashicons-media-document' => 'f497',
'dashicons-media-interactive' => 'f496',
'dashicons-media-spreadsheet' => 'f495',
'dashicons-media-text' => 'f491',
'dashicons-media-video' => 'f490',
'dashicons-megaphone' => 'f488',
'dashicons-menu' => 'f333',
'dashicons-microphone' => 'f482',
'dashicons-migrate' => 'f310',
'dashicons-minus' => 'f460',
'dashicons-money' => 'f526',
'dashicons-move' => 'f545',
'dashicons-nametag' => 'f484',
'dashicons-networking' => 'f325',
'dashicons-no' => 'f158',
'dashicons-no-alt' => 'f335',
'dashicons-palmtree' => 'f527',
'dashicons-paperclip' => 'f546',
'dashicons-performance' => 'f311',
'dashicons-phone' => 'f525',
'dashicons-playlist-audio' => 'f492',
'dashicons-playlist-video' => 'f493',
'dashicons-plus' => 'f132',
'dashicons-plus-alt' => 'f502',
'dashicons-portfolio' => 'f322',
'dashicons-post-status' => 'f173',
'dashicons-pressthis' => 'f157',
'dashicons-products' => 'f312',
'dashicons-randomize' => 'f503',
'dashicons-redo' => 'f172',
'dashicons-rss' => 'f303',
'dashicons-schedule' => 'f489',
'dashicons-screenoptions' => 'f180',
'dashicons-search' => 'f179',
'dashicons-share' => 'f237',
'dashicons-share-alt' => 'f240',
'dashicons-share-alt2' => 'f242',
'dashicons-shield' => 'f332',
'dashicons-shield-alt' => 'f334',
'dashicons-slides' => 'f181',
'dashicons-smartphone' => 'f470',
'dashicons-smiley' => 'f328',
'dashicons-sort' => 'f156',
'dashicons-sos' => 'f468',
'dashicons-star-empty' => 'f154',
'dashicons-star-filled' => 'f155',
'dashicons-star-half' => 'f459',
'dashicons-sticky' => 'f537',
'dashicons-store' => 'f513',
'dashicons-tablet' => 'f471',
'dashicons-tag' => 'f323',
'dashicons-tagcloud' => 'f479',
'dashicons-testimonial' => 'f473',
'dashicons-text' => 'f478',
'dashicons-thumbs-down' => 'f542',
'dashicons-thumbs-up' => 'f529',
'dashicons-tickets' => 'f486',
'dashicons-tickets-alt' => 'f524',
'dashicons-translation' => 'f326',
'dashicons-trash' => 'f182',
'dashicons-twitter' => 'f301',
'dashicons-undo' => 'f171',
'dashicons-universal-access' => 'f483',
'dashicons-universal-access-alt' => 'f507',
'dashicons-unlock' => 'f528',
'dashicons-update' => 'f463',
'dashicons-upload' => 'f317',
'dashicons-vault' => 'f178',
'dashicons-video-alt' => 'f234',
'dashicons-video-alt2' => 'f235',
'dashicons-video-alt3' => 'f236',
'dashicons-visibility' => 'f177',
'dashicons-warning' => 'f534',
'dashicons-welcome-add-page' => 'f133',
'dashicons-welcome-comments' => 'f117',
'dashicons-welcome-learn-more' => 'f118',
'dashicons-welcome-view-site' => 'f115',
'dashicons-welcome-widgets-menus' => 'f116',
'dashicons-welcome-write-blog' => 'f119',
'dashicons-wordpress' => 'f120',
'dashicons-wordpress-alt' => 'f324',
'dashicons-yes' => 'f147',
);

return apply_filters( 'geodir_dashicon_options', $dashicons );
}
62 changes: 62 additions & 0 deletions includes/admin/class-geodir-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,68 @@ class="regular-text <?php echo esc_attr( $value['class'] ); ?>"
</td>
</tr><?php
break;
case 'dashicon' :
$value['options'] = geodir_dashicon_options();

if ( isset( $value['value'] ) ) {
$option_value = $value['value'];
} else {
$option_value = self::get_option( $value['id'], $value['default'] );
}
$option_value = GeoDir_Post_types::sanitize_menu_icon( $option_value );

?><tr valign="top" class="<?php if(isset($value['advanced']) && $value['advanced']){echo "gd-advanced-setting";}?>">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
<?php echo $tooltip_html; ?>
</th>
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
<select
name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
style="<?php echo esc_attr( $value['css'] ); ?>"
class="regular-text <?php echo esc_attr( $value['class'] ); ?>"
<?php echo implode( ' ', $custom_attributes ); ?>
<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
>
<?php
foreach ( $value['options'] as $key => $val ) {
?>
<option value="<?php echo esc_attr( $key ); ?>" data-dashicon="<?php echo esc_attr( $key ); ?>" <?php
if ( is_array( $option_value ) ) {
selected( in_array( $key, $option_value ), true );
} else {
selected( $option_value, $key );
}
?>><?php echo str_replace( 'dashicons-', '', $key ); ?></option>
<?php
}
?>
</select> <?php echo $description; ?>
</td>
</tr><?php
break;
case 'hidden' :
if ( isset( $value['value'] ) ) {
$option_value = $value['value'];
} else {
$option_value = self::get_option( $value['id'], $value['default'] );
}
?><tr valign="top" style="display:none!important">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
</th>
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
<input
name="<?php echo esc_attr( $value['id'] ); ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
type="hidden"
value="<?php echo esc_attr( $option_value ); ?>"
<?php echo implode( ' ', $custom_attributes ); ?>
/> <?php echo $description; ?>
</td>
</tr><?php
break;

// Default: run an action
default:
Expand Down
16 changes: 9 additions & 7 deletions includes/admin/settings/class-geodir-settings-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ public function get_settings( $current_section = '' ) {
$post_type_values['meta_title'] = ( ! empty( $post_type_option['seo']['meta_title'] ) ? $post_type_option['seo']['meta_title'] : '' );
$post_type_values['meta_description'] = ( ! empty( $post_type_option['seo']['meta_description'] ) ? $post_type_option['seo']['meta_description'] : '' );

// print_r( $post_type_values );

// we need to trick the settings to show the current values
$settings = apply_filters( "geodir_cpt_settings_{$post_type}", array(

Expand Down Expand Up @@ -244,13 +242,17 @@ public function get_settings( $current_section = '' ) {
),
array(
'name' => __( 'Menu icon', 'geodirectory' ),
'desc' => __( 'The image to be used as the menu icon (16px x 16px recommended)', 'geodirectory' ),
'desc' => __( 'The icon to be used in the admin menu from the post type.', 'geodirectory' ),
'class' => 'geodir-select',
'id' => 'menu_icon',
'type' => 'image',
'default' => '',
'type' => 'dashicon',
'default' => 'admin-site',
'desc_tip' => true,
'advanced' => true,
'value' => $post_type_values['menu_icon']
'value' => $post_type_values['menu_icon'],
'custom_attributes' => array(
'data-dashicons' => true
)
),

array(
Expand Down Expand Up @@ -635,7 +637,7 @@ public static function sanatize_post_type( $raw ) {
$output[$post_type]['seo']['meta_title'] = isset($raw['meta_title']) && $raw['meta_title'] ? sanitize_text_field($raw['meta_title']) : '';
$output[$post_type]['seo']['meta_description'] = isset($raw['meta_description']) && $raw['meta_description'] ? sanitize_text_field($raw['meta_description']) : '';

$output[$post_type]['menu_icon'] = !empty( $raw['menu_icon'] ) ? $raw['menu_icon'] : 'dashicons-admin-post';
$output[$post_type]['menu_icon'] = !empty( $raw['menu_icon'] ) ? GeoDir_Post_types::sanitize_menu_icon( $raw['menu_icon'] ) : 'dashicons-admin-post';
$output[$post_type]['default_image'] = !empty( $raw['default_image'] ) ? $raw['default_image'] : '';

return apply_filters('geodir_save_post_type', $output, $post_type, $raw);
Expand Down
Loading

0 comments on commit e19b8d0

Please sign in to comment.