@@ -33,257 +33,257 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function geodir_add_nav_menu_items() |
| 35 | 35 | {
|
| 36 | - $items = ''; |
|
| 37 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | - |
|
| 39 | - if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | - |
|
| 41 | - $menu_class = ''; |
|
| 42 | - if (geodir_is_page('listing'))
|
|
| 43 | - $menu_class = 'current-menu-item'; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | - $post_types = geodir_get_posttypes('object');
|
|
| 48 | - $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | - if (!empty($post_types)) {
|
|
| 50 | - foreach ($post_types as $post_type => $args) {
|
|
| 51 | - if (!empty($show_post_type_main_nav)) {
|
|
| 52 | - if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | - if (get_post_type_archive_link($post_type)) {
|
|
| 54 | - $menu_class = ''; |
|
| 55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | - $menu_class = 'current-menu-item'; |
|
| 57 | - /** |
|
| 58 | - * Filter the menu li class. |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @param string $menu_class The menu HTML class. |
|
| 62 | - */ |
|
| 63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | - /** |
|
| 65 | - * Filter the menu a class. |
|
| 66 | - * |
|
| 67 | - * @since 1.0.0 |
|
| 68 | - */ |
|
| 69 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | - $items .= '<li class="' . $li_class . '"> |
|
| 36 | + $items = ''; |
|
| 37 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 38 | + |
|
| 39 | + if (get_option('geodir_show_listing_nav')) {
|
|
| 40 | + |
|
| 41 | + $menu_class = ''; |
|
| 42 | + if (geodir_is_page('listing'))
|
|
| 43 | + $menu_class = 'current-menu-item'; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 47 | + $post_types = geodir_get_posttypes('object');
|
|
| 48 | + $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
|
|
| 49 | + if (!empty($post_types)) {
|
|
| 50 | + foreach ($post_types as $post_type => $args) {
|
|
| 51 | + if (!empty($show_post_type_main_nav)) {
|
|
| 52 | + if (in_array($post_type, $show_post_type_main_nav)) {
|
|
| 53 | + if (get_post_type_archive_link($post_type)) {
|
|
| 54 | + $menu_class = ''; |
|
| 55 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 56 | + $menu_class = 'current-menu-item'; |
|
| 57 | + /** |
|
| 58 | + * Filter the menu li class. |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @param string $menu_class The menu HTML class. |
|
| 62 | + */ |
|
| 63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 64 | + /** |
|
| 65 | + * Filter the menu a class. |
|
| 66 | + * |
|
| 67 | + * @since 1.0.0 |
|
| 68 | + */ |
|
| 69 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 70 | + $items .= '<li class="' . $li_class . '"> |
|
| 71 | 71 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
| 72 | 72 | ' . __(ucfirst($args->labels->name)) . ' |
| 73 | 73 | </a> |
| 74 | 74 | </li>'; |
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | - |
|
| 82 | - $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | - $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | - if ($is_listing_sub_meny_exists) {
|
|
| 85 | - /** |
|
| 86 | - * Filter the menu li class. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.0 |
|
| 89 | - * @param string $menu_class The menu HTML class. |
|
| 90 | - */ |
|
| 91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | - /** |
|
| 93 | - * Filter the sub menu li class. |
|
| 94 | - * |
|
| 95 | - * @since 1.0.0 |
|
| 96 | - * @param string $menu_class The menu HTML class. |
|
| 97 | - */ |
|
| 98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | - /** |
|
| 100 | - * Filter the sub menu ul class. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - */ |
|
| 104 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | - /** |
|
| 106 | - * Filter the menu a class. |
|
| 107 | - * |
|
| 108 | - * @since 1.0.0 |
|
| 109 | - */ |
|
| 110 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | - /** |
|
| 112 | - * Filter the sub menu a class. |
|
| 113 | - * |
|
| 114 | - * @since 1.0.0 |
|
| 115 | - */ |
|
| 116 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | - $items .= '<li class="' . $li_class . '"> |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
| 81 | + |
|
| 82 | + $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 83 | + $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
| 84 | + if ($is_listing_sub_meny_exists) {
|
|
| 85 | + /** |
|
| 86 | + * Filter the menu li class. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.0 |
|
| 89 | + * @param string $menu_class The menu HTML class. |
|
| 90 | + */ |
|
| 91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
|
|
| 92 | + /** |
|
| 93 | + * Filter the sub menu li class. |
|
| 94 | + * |
|
| 95 | + * @since 1.0.0 |
|
| 96 | + * @param string $menu_class The menu HTML class. |
|
| 97 | + */ |
|
| 98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 99 | + /** |
|
| 100 | + * Filter the sub menu ul class. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + */ |
|
| 104 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 105 | + /** |
|
| 106 | + * Filter the menu a class. |
|
| 107 | + * |
|
| 108 | + * @since 1.0.0 |
|
| 109 | + */ |
|
| 110 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 111 | + /** |
|
| 112 | + * Filter the sub menu a class. |
|
| 113 | + * |
|
| 114 | + * @since 1.0.0 |
|
| 115 | + */ |
|
| 116 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 117 | + $items .= '<li class="' . $li_class . '"> |
|
| 118 | 118 | <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
|
| 119 | 119 | <ul class="' . $sub_ul_class . '">'; |
| 120 | - $post_types = geodir_get_posttypes('object');
|
|
| 120 | + $post_types = geodir_get_posttypes('object');
|
|
| 121 | 121 | |
| 122 | - $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 122 | + $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
|
|
| 123 | 123 | |
| 124 | - if (!empty($post_types)) {
|
|
| 125 | - global $geodir_add_location_url; |
|
| 126 | - $geodir_add_location_url = true; |
|
| 127 | - foreach ($post_types as $post_type => $args) {
|
|
| 128 | - if (!empty($show_listing_post_types)) {
|
|
| 129 | - if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | - if (get_post_type_archive_link($post_type)) {
|
|
| 124 | + if (!empty($post_types)) {
|
|
| 125 | + global $geodir_add_location_url; |
|
| 126 | + $geodir_add_location_url = true; |
|
| 127 | + foreach ($post_types as $post_type => $args) {
|
|
| 128 | + if (!empty($show_listing_post_types)) {
|
|
| 129 | + if (in_array($post_type, $show_listing_post_types)) {
|
|
| 130 | + if (get_post_type_archive_link($post_type)) {
|
|
| 131 | 131 | |
| 132 | - $menu_class = ''; |
|
| 133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | - $menu_class = 'current-menu-item'; |
|
| 132 | + $menu_class = ''; |
|
| 133 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
|
|
| 134 | + $menu_class = 'current-menu-item'; |
|
| 135 | 135 | |
| 136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
| 136 | + $items .= '<li class="' . $sub_li_class . '"> |
|
| 137 | 137 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
| 138 | 138 | ' . __(ucfirst($args->labels->name),'geodirectory') . ' |
| 139 | 139 | </a> |
| 140 | 140 | </li>'; |
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - $geodir_add_location_url = NULL; |
|
| 146 | - } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + $geodir_add_location_url = NULL; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $items .= ' </ul> |
|
| 148 | + $items .= ' </ul> |
|
| 149 | 149 | </li>'; |
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 154 | - |
|
| 155 | - $menu_class = ''; |
|
| 156 | - if (geodir_is_page('add-listing'))
|
|
| 157 | - $menu_class = 'current-menu-item'; |
|
| 158 | - |
|
| 159 | - //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 160 | - $post_types = geodir_get_posttypes('object');
|
|
| 161 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 162 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 163 | - |
|
| 164 | - if (!empty($post_types)) {
|
|
| 165 | - foreach ($post_types as $post_type => $args) {
|
|
| 166 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 167 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 168 | - if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 169 | - if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 170 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 171 | - |
|
| 172 | - $menu_class = ''; |
|
| 173 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 174 | - $menu_class = 'current-menu-item'; |
|
| 175 | - /** |
|
| 176 | - * Filter the menu li class. |
|
| 177 | - * |
|
| 178 | - * @since 1.0.0 |
|
| 179 | - * @param string $menu_class The menu HTML class. |
|
| 180 | - */ |
|
| 181 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 182 | - /** |
|
| 183 | - * Filter the menu a class. |
|
| 184 | - * |
|
| 185 | - * @since 1.0.0 |
|
| 186 | - */ |
|
| 187 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 188 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 189 | - $items .= '<li class="' . $li_class . '"> |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 154 | + |
|
| 155 | + $menu_class = ''; |
|
| 156 | + if (geodir_is_page('add-listing'))
|
|
| 157 | + $menu_class = 'current-menu-item'; |
|
| 158 | + |
|
| 159 | + //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 160 | + $post_types = geodir_get_posttypes('object');
|
|
| 161 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
|
|
| 162 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 163 | + |
|
| 164 | + if (!empty($post_types)) {
|
|
| 165 | + foreach ($post_types as $post_type => $args) {
|
|
| 166 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 167 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 168 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 169 | + if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
|
|
| 170 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 171 | + |
|
| 172 | + $menu_class = ''; |
|
| 173 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 174 | + $menu_class = 'current-menu-item'; |
|
| 175 | + /** |
|
| 176 | + * Filter the menu li class. |
|
| 177 | + * |
|
| 178 | + * @since 1.0.0 |
|
| 179 | + * @param string $menu_class The menu HTML class. |
|
| 180 | + */ |
|
| 181 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 182 | + /** |
|
| 183 | + * Filter the menu a class. |
|
| 184 | + * |
|
| 185 | + * @since 1.0.0 |
|
| 186 | + */ |
|
| 187 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 188 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 189 | + $items .= '<li class="' . $li_class . '"> |
|
| 190 | 190 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
| 191 | 191 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 192 | 192 | </a> |
| 193 | 193 | </li>'; |
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 205 | - $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 206 | - if ($is_add_listing_sub_meny_exists) {
|
|
| 207 | - |
|
| 208 | - if (get_option('geodir_show_addlisting_nav')) {
|
|
| 209 | - /** |
|
| 210 | - * Filter the menu li class. |
|
| 211 | - * |
|
| 212 | - * @since 1.0.0 |
|
| 213 | - * @param string $menu_class The menu HTML class. |
|
| 214 | - */ |
|
| 215 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 216 | - /** |
|
| 217 | - * Filter the sub menu li class. |
|
| 218 | - * |
|
| 219 | - * @since 1.0.0 |
|
| 220 | - * @param string $menu_class The menu HTML class. |
|
| 221 | - */ |
|
| 222 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 223 | - /** |
|
| 224 | - * Filter the sub menu ul class. |
|
| 225 | - * |
|
| 226 | - * @since 1.0.0 |
|
| 227 | - */ |
|
| 228 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 229 | - /** |
|
| 230 | - * Filter the menu a class. |
|
| 231 | - * |
|
| 232 | - * @since 1.0.0 |
|
| 233 | - */ |
|
| 234 | - $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 235 | - /** |
|
| 236 | - * Filter the sub menu a class. |
|
| 237 | - * |
|
| 238 | - * @since 1.0.0 |
|
| 239 | - */ |
|
| 240 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 241 | - $items .= '<li class="' . $li_class . '"> |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 205 | + $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
| 206 | + if ($is_add_listing_sub_meny_exists) {
|
|
| 207 | + |
|
| 208 | + if (get_option('geodir_show_addlisting_nav')) {
|
|
| 209 | + /** |
|
| 210 | + * Filter the menu li class. |
|
| 211 | + * |
|
| 212 | + * @since 1.0.0 |
|
| 213 | + * @param string $menu_class The menu HTML class. |
|
| 214 | + */ |
|
| 215 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
|
|
| 216 | + /** |
|
| 217 | + * Filter the sub menu li class. |
|
| 218 | + * |
|
| 219 | + * @since 1.0.0 |
|
| 220 | + * @param string $menu_class The menu HTML class. |
|
| 221 | + */ |
|
| 222 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 223 | + /** |
|
| 224 | + * Filter the sub menu ul class. |
|
| 225 | + * |
|
| 226 | + * @since 1.0.0 |
|
| 227 | + */ |
|
| 228 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
|
|
| 229 | + /** |
|
| 230 | + * Filter the menu a class. |
|
| 231 | + * |
|
| 232 | + * @since 1.0.0 |
|
| 233 | + */ |
|
| 234 | + $a_class = apply_filters('geodir_menu_a_class', '');
|
|
| 235 | + /** |
|
| 236 | + * Filter the sub menu a class. |
|
| 237 | + * |
|
| 238 | + * @since 1.0.0 |
|
| 239 | + */ |
|
| 240 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
|
|
| 241 | + $items .= '<li class="' . $li_class . '"> |
|
| 242 | 242 | <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
|
| 243 | 243 | <ul class="' . $sub_ul_class . '">'; |
| 244 | 244 | |
| 245 | - $post_types = geodir_get_posttypes('object');
|
|
| 246 | - |
|
| 247 | - $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 248 | - |
|
| 249 | - if (!empty($post_types)) {
|
|
| 250 | - foreach ($post_types as $post_type => $args) {
|
|
| 251 | - if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 252 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 253 | - if (!empty($show_add_listing_post_types)) {
|
|
| 254 | - if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 255 | - if (geodir_get_addlisting_link($post_type)) {
|
|
| 256 | - |
|
| 257 | - $menu_class = ''; |
|
| 258 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 259 | - $menu_class = 'current-menu-item'; |
|
| 260 | - /** |
|
| 261 | - * Filter the menu li class. |
|
| 262 | - * |
|
| 263 | - * @since 1.0.0 |
|
| 264 | - * @param string $menu_class The menu HTML class. |
|
| 265 | - */ |
|
| 266 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 267 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 268 | - $items .= '<li class="' . $li_class . '"> |
|
| 245 | + $post_types = geodir_get_posttypes('object');
|
|
| 246 | + |
|
| 247 | + $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
|
|
| 248 | + |
|
| 249 | + if (!empty($post_types)) {
|
|
| 250 | + foreach ($post_types as $post_type => $args) {
|
|
| 251 | + if (!empty($geodir_allow_posttype_frontend)) {
|
|
| 252 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) {
|
|
| 253 | + if (!empty($show_add_listing_post_types)) {
|
|
| 254 | + if (in_array($post_type, $show_add_listing_post_types)) {
|
|
| 255 | + if (geodir_get_addlisting_link($post_type)) {
|
|
| 256 | + |
|
| 257 | + $menu_class = ''; |
|
| 258 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
|
|
| 259 | + $menu_class = 'current-menu-item'; |
|
| 260 | + /** |
|
| 261 | + * Filter the menu li class. |
|
| 262 | + * |
|
| 263 | + * @since 1.0.0 |
|
| 264 | + * @param string $menu_class The menu HTML class. |
|
| 265 | + */ |
|
| 266 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
|
|
| 267 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
| 268 | + $items .= '<li class="' . $li_class . '"> |
|
| 269 | 269 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
| 270 | 270 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
|
| 271 | 271 | </a> |
| 272 | 272 | </li>'; |
| 273 | - } |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - $items .= ' </ul> |
|
| 281 | + $items .= ' </ul> |
|
| 282 | 282 | </li>'; |
| 283 | - } |
|
| 284 | - } |
|
| 285 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
| 286 | - return $items; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
| 286 | + return $items; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
@@ -301,20 +301,20 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | function geodir_pagemenu_items($menu, $args) |
| 303 | 303 | {
|
| 304 | - $locations = get_nav_menu_locations(); |
|
| 305 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 306 | - $geodir_theme_location_nav = array(); |
|
| 307 | - if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 308 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 309 | - $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 310 | - update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 311 | - } |
|
| 312 | - //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 304 | + $locations = get_nav_menu_locations(); |
|
| 305 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 306 | + $geodir_theme_location_nav = array(); |
|
| 307 | + if (empty($locations) && empty($geodir_theme_location)) {
|
|
| 308 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 309 | + $geodir_theme_location_nav[] = $args['theme_location']; |
|
| 310 | + update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
|
|
| 311 | + } |
|
| 312 | + //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
| 313 | 313 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
|
| 314 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 315 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 314 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
| 315 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
|
|
| 316 | 316 | |
| 317 | - return $menu; |
|
| 317 | + return $menu; |
|
| 318 | 318 | |
| 319 | 319 | } |
| 320 | 320 | |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | function geodir_menu_items($items, $args) |
| 335 | 335 | {
|
| 336 | 336 | |
| 337 | - $location = $args->theme_location; |
|
| 337 | + $location = $args->theme_location; |
|
| 338 | 338 | |
| 339 | - $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 339 | + $geodir_theme_location = get_option('geodir_theme_location_nav');
|
|
| 340 | 340 | |
| 341 | - if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 341 | + if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
|
|
| 342 | 342 | |
| 343 | - $items = $items . geodir_add_nav_menu_items(); |
|
| 344 | - return $items; |
|
| 343 | + $items = $items . geodir_add_nav_menu_items(); |
|
| 344 | + return $items; |
|
| 345 | 345 | |
| 346 | - } else {
|
|
| 347 | - return $items; |
|
| 348 | - } |
|
| 346 | + } else {
|
|
| 347 | + return $items; |
|
| 348 | + } |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -360,25 +360,25 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function geodir_get_category_all_array() |
| 362 | 362 | {
|
| 363 | - global $wpdb; |
|
| 364 | - $return_array = array(); |
|
| 365 | - |
|
| 366 | - $taxonomies = geodir_get_taxonomies(); |
|
| 367 | - $taxonomies = implode("','", $taxonomies);
|
|
| 368 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 369 | - |
|
| 370 | - $pn_categories = $wpdb->get_results( |
|
| 371 | - $wpdb->prepare( |
|
| 372 | - "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 373 | - array($wpdb->terms . term_id) |
|
| 374 | - ) |
|
| 375 | - ); |
|
| 376 | - |
|
| 377 | - foreach ($pn_categories as $pn_categories_obj) {
|
|
| 378 | - $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 379 | - "title" => $pn_categories_obj->name,); |
|
| 380 | - } |
|
| 381 | - return $return_array; |
|
| 363 | + global $wpdb; |
|
| 364 | + $return_array = array(); |
|
| 365 | + |
|
| 366 | + $taxonomies = geodir_get_taxonomies(); |
|
| 367 | + $taxonomies = implode("','", $taxonomies);
|
|
| 368 | + $taxonomies = "'" . $taxonomies . "'"; |
|
| 369 | + |
|
| 370 | + $pn_categories = $wpdb->get_results( |
|
| 371 | + $wpdb->prepare( |
|
| 372 | + "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
| 373 | + array($wpdb->terms . term_id) |
|
| 374 | + ) |
|
| 375 | + ); |
|
| 376 | + |
|
| 377 | + foreach ($pn_categories as $pn_categories_obj) {
|
|
| 378 | + $return_array[] = array("id" => $pn_categories_obj->cat_ID,
|
|
| 379 | + "title" => $pn_categories_obj->name,); |
|
| 380 | + } |
|
| 381 | + return $return_array; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
@@ -393,32 +393,32 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function geodir_get_current_posttype() |
| 395 | 395 | {
|
| 396 | - global $wp_query, $geodir_post_type; |
|
| 396 | + global $wp_query, $geodir_post_type; |
|
| 397 | 397 | |
| 398 | - $geodir_post_type = get_query_var('post_type');
|
|
| 398 | + $geodir_post_type = get_query_var('post_type');
|
|
| 399 | 399 | |
| 400 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 401 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 402 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 403 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 404 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 405 | - } |
|
| 400 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
|
| 401 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 402 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 403 | + elseif (isset($_REQUEST['listing_type'])) |
|
| 404 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 408 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 407 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 408 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 409 | 409 | |
| 410 | - if (is_tax()) |
|
| 411 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 410 | + if (is_tax()) |
|
| 411 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 412 | 412 | |
| 413 | 413 | |
| 414 | - $all_postypes = geodir_get_posttypes(); |
|
| 415 | - $all_postypes = stripslashes_deep($all_postypes); |
|
| 414 | + $all_postypes = geodir_get_posttypes(); |
|
| 415 | + $all_postypes = stripslashes_deep($all_postypes); |
|
| 416 | 416 | |
| 417 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 418 | - $geodir_post_type = ''; |
|
| 417 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 418 | + $geodir_post_type = ''; |
|
| 419 | 419 | |
| 420 | 420 | |
| 421 | - return $geodir_post_type; |
|
| 421 | + return $geodir_post_type; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | function geodir_get_posttypes($output = 'names') |
| 434 | 434 | {
|
| 435 | - $post_types = array(); |
|
| 436 | - $post_types = get_option('geodir_post_types');
|
|
| 437 | - $post_types = stripslashes_deep($post_types); |
|
| 438 | - if (!empty($post_types)) {
|
|
| 439 | - switch ($output): |
|
| 440 | - case 'object': |
|
| 441 | - case 'Object': |
|
| 442 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 443 | - break; |
|
| 444 | - case 'array': |
|
| 445 | - case 'Array': |
|
| 446 | - $post_types = (array)$post_types; |
|
| 447 | - break; |
|
| 435 | + $post_types = array(); |
|
| 436 | + $post_types = get_option('geodir_post_types');
|
|
| 437 | + $post_types = stripslashes_deep($post_types); |
|
| 438 | + if (!empty($post_types)) {
|
|
| 439 | + switch ($output): |
|
| 440 | + case 'object': |
|
| 441 | + case 'Object': |
|
| 442 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
| 443 | + break; |
|
| 444 | + case 'array': |
|
| 445 | + case 'Array': |
|
| 446 | + $post_types = (array)$post_types; |
|
| 447 | + break; |
|
| 448 | 448 | case 'options': |
| 449 | - $post_types = (array)$post_types; |
|
| 449 | + $post_types = (array)$post_types; |
|
| 450 | 450 | |
| 451 | 451 | $options = array(); |
| 452 | 452 | if (!empty($post_types)) {
|
@@ -455,17 +455,17 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | $post_types = $options; |
| 458 | - break; |
|
| 459 | - default: |
|
| 460 | - $post_types = array_keys($post_types); |
|
| 461 | - break; |
|
| 462 | - endswitch; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - if (!empty($post_types)) |
|
| 466 | - return $post_types; |
|
| 467 | - else |
|
| 468 | - return array(); |
|
| 458 | + break; |
|
| 459 | + default: |
|
| 460 | + $post_types = array_keys($post_types); |
|
| 461 | + break; |
|
| 462 | + endswitch; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + if (!empty($post_types)) |
|
| 466 | + return $post_types; |
|
| 467 | + else |
|
| 468 | + return array(); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -478,108 +478,108 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | function geodir_get_posttype_info($post_type = '') |
| 480 | 480 | {
|
| 481 | - $post_types = array(); |
|
| 482 | - $post_types = get_option('geodir_post_types');
|
|
| 483 | - $post_types = stripslashes_deep($post_types); |
|
| 484 | - if (!empty($post_types) && $post_type != '') {
|
|
| 485 | - return $post_types[$post_type]; |
|
| 486 | - } else |
|
| 487 | - return false; |
|
| 481 | + $post_types = array(); |
|
| 482 | + $post_types = get_option('geodir_post_types');
|
|
| 483 | + $post_types = stripslashes_deep($post_types); |
|
| 484 | + if (!empty($post_types) && $post_type != '') {
|
|
| 485 | + return $post_types[$post_type]; |
|
| 486 | + } else |
|
| 487 | + return false; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | if (!function_exists('geodir_get_taxonomies')) {
|
| 491 | - /** |
|
| 492 | - * Get all custom taxonomies. |
|
| 493 | - * |
|
| 494 | - * @since 1.0.0 |
|
| 495 | - * @package GeoDirectory |
|
| 496 | - * @param string $post_type The post type. |
|
| 497 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 498 | - * @return array|bool Taxonomies on success. false on failure. |
|
| 499 | - */ |
|
| 500 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 501 | - {
|
|
| 491 | + /** |
|
| 492 | + * Get all custom taxonomies. |
|
| 493 | + * |
|
| 494 | + * @since 1.0.0 |
|
| 495 | + * @package GeoDirectory |
|
| 496 | + * @param string $post_type The post type. |
|
| 497 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 498 | + * @return array|bool Taxonomies on success. false on failure. |
|
| 499 | + */ |
|
| 500 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
| 501 | + {
|
|
| 502 | 502 | |
| 503 | - $taxonomies = array(); |
|
| 504 | - $gd_taxonomies = array(); |
|
| 503 | + $taxonomies = array(); |
|
| 504 | + $gd_taxonomies = array(); |
|
| 505 | 505 | |
| 506 | - if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 506 | + if ($taxonomies = get_option('geodir_taxonomies')) {
|
|
| 507 | 507 | |
| 508 | 508 | |
| 509 | - $gd_taxonomies = array_keys($taxonomies); |
|
| 509 | + $gd_taxonomies = array_keys($taxonomies); |
|
| 510 | 510 | |
| 511 | 511 | |
| 512 | - if ($post_type != '') |
|
| 513 | - $gd_taxonomies = array(); |
|
| 512 | + if ($post_type != '') |
|
| 513 | + $gd_taxonomies = array(); |
|
| 514 | 514 | |
| 515 | - $i = 0; |
|
| 516 | - foreach ($taxonomies as $taxonomy => $args) {
|
|
| 515 | + $i = 0; |
|
| 516 | + foreach ($taxonomies as $taxonomy => $args) {
|
|
| 517 | 517 | |
| 518 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 519 | - $gd_taxonomies[] = $taxonomy; |
|
| 518 | + if ($post_type != '' && $args['object_type'] == $post_type) |
|
| 519 | + $gd_taxonomies[] = $taxonomy; |
|
| 520 | 520 | |
| 521 | - if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 522 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 523 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 524 | - } |
|
| 521 | + if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
|
|
| 522 | + if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
| 523 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
| 529 | + } |
|
| 527 | 530 | |
| 528 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * Filter the taxonomies. |
|
| 533 | - * |
|
| 534 | - * @since 1.0.0 |
|
| 535 | - * @param array $gd_taxonomies The taxonomy array. |
|
| 536 | - */ |
|
| 537 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 538 | - |
|
| 539 | - if (!empty($taxonomies)) {
|
|
| 540 | - return $taxonomies; |
|
| 541 | - } else {
|
|
| 542 | - return false; |
|
| 543 | - } |
|
| 544 | - } |
|
| 531 | + /** |
|
| 532 | + * Filter the taxonomies. |
|
| 533 | + * |
|
| 534 | + * @since 1.0.0 |
|
| 535 | + * @param array $gd_taxonomies The taxonomy array. |
|
| 536 | + */ |
|
| 537 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
|
|
| 538 | + |
|
| 539 | + if (!empty($taxonomies)) {
|
|
| 540 | + return $taxonomies; |
|
| 541 | + } else {
|
|
| 542 | + return false; |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | if (!function_exists(' geodir_get_categories_dl')) {
|
| 548 | - /** |
|
| 549 | - * Get categories dropdown HTML. |
|
| 550 | - * |
|
| 551 | - * @since 1.0.0 |
|
| 552 | - * @package GeoDirectory |
|
| 553 | - * @param string $post_type The post type. |
|
| 554 | - * @param string $selected The selected value. |
|
| 555 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 556 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 557 | - * @return void|string Dropdown HTML. |
|
| 558 | - */ |
|
| 559 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 560 | - {
|
|
| 561 | - |
|
| 562 | - $html = ''; |
|
| 563 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 564 | - |
|
| 565 | - $categories = get_terms($taxonomies); |
|
| 566 | - |
|
| 567 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 568 | - |
|
| 569 | - foreach ($categories as $category_obj) {
|
|
| 570 | - $select_opt = ''; |
|
| 571 | - if ($selected == $category_obj->term_id) {
|
|
| 572 | - $select_opt = 'selected="selected"'; |
|
| 573 | - } |
|
| 574 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 575 | - . ucfirst($category_obj->name) . '</option>'; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - if ($echo) |
|
| 579 | - echo $html; |
|
| 580 | - else |
|
| 581 | - return $html; |
|
| 582 | - } |
|
| 548 | + /** |
|
| 549 | + * Get categories dropdown HTML. |
|
| 550 | + * |
|
| 551 | + * @since 1.0.0 |
|
| 552 | + * @package GeoDirectory |
|
| 553 | + * @param string $post_type The post type. |
|
| 554 | + * @param string $selected The selected value. |
|
| 555 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
| 556 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
| 557 | + * @return void|string Dropdown HTML. |
|
| 558 | + */ |
|
| 559 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
| 560 | + {
|
|
| 561 | + |
|
| 562 | + $html = ''; |
|
| 563 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
| 564 | + |
|
| 565 | + $categories = get_terms($taxonomies); |
|
| 566 | + |
|
| 567 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
|
|
| 568 | + |
|
| 569 | + foreach ($categories as $category_obj) {
|
|
| 570 | + $select_opt = ''; |
|
| 571 | + if ($selected == $category_obj->term_id) {
|
|
| 572 | + $select_opt = 'selected="selected"'; |
|
| 573 | + } |
|
| 574 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
| 575 | + . ucfirst($category_obj->name) . '</option>'; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + if ($echo) |
|
| 579 | + echo $html; |
|
| 580 | + else |
|
| 581 | + return $html; |
|
| 582 | + } |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
@@ -594,28 +594,28 @@ discard block |
||
| 594 | 594 | function geodir_get_listing_slug($object_type = '') |
| 595 | 595 | {
|
| 596 | 596 | |
| 597 | - $listing_slug = ''; |
|
| 597 | + $listing_slug = ''; |
|
| 598 | 598 | |
| 599 | - $post_types = get_option('geodir_post_types');
|
|
| 600 | - $taxonomies = get_option('geodir_taxonomies');
|
|
| 599 | + $post_types = get_option('geodir_post_types');
|
|
| 600 | + $taxonomies = get_option('geodir_taxonomies');
|
|
| 601 | 601 | |
| 602 | 602 | |
| 603 | - if ($object_type != '') {
|
|
| 604 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 603 | + if ($object_type != '') {
|
|
| 604 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
|
|
| 605 | 605 | |
| 606 | - $object_info = $post_types[$object_type]; |
|
| 607 | - $listing_slug = $object_info['listing_slug']; |
|
| 608 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 609 | - $object_info = $taxonomies[$object_type]; |
|
| 610 | - $listing_slug = $object_info['listing_slug']; |
|
| 611 | - } |
|
| 606 | + $object_info = $post_types[$object_type]; |
|
| 607 | + $listing_slug = $object_info['listing_slug']; |
|
| 608 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
|
|
| 609 | + $object_info = $taxonomies[$object_type]; |
|
| 610 | + $listing_slug = $object_info['listing_slug']; |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - } |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - if (!empty($listing_slug)) |
|
| 616 | - return $listing_slug; |
|
| 617 | - else |
|
| 618 | - return false; |
|
| 615 | + if (!empty($listing_slug)) |
|
| 616 | + return $listing_slug; |
|
| 617 | + else |
|
| 618 | + return false; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | |
@@ -630,212 +630,212 @@ discard block |
||
| 630 | 630 | */ |
| 631 | 631 | function geodir_get_taxonomy_posttype($taxonomy = '') |
| 632 | 632 | {
|
| 633 | - global $wp_query; |
|
| 634 | - |
|
| 635 | - $post_type = array(); |
|
| 636 | - $taxonomies = array(); |
|
| 637 | - |
|
| 638 | - if (!empty($taxonomy)) {
|
|
| 639 | - $taxonomies[] = $taxonomy; |
|
| 640 | - } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 641 | - $tax_arr = $wp_query->tax_query->queries; |
|
| 642 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 643 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 644 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - if (!empty($taxonomies)) {
|
|
| 648 | - foreach (geodir_get_posttypes() as $pt) {
|
|
| 649 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 650 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 651 | - $post_type[] = $pt; |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - if (!empty($post_type)) |
|
| 656 | - return $post_type[0]; |
|
| 657 | - else |
|
| 658 | - return false; |
|
| 633 | + global $wp_query; |
|
| 634 | + |
|
| 635 | + $post_type = array(); |
|
| 636 | + $taxonomies = array(); |
|
| 637 | + |
|
| 638 | + if (!empty($taxonomy)) {
|
|
| 639 | + $taxonomies[] = $taxonomy; |
|
| 640 | + } elseif (isset($wp_query->tax_query->queries)) {
|
|
| 641 | + $tax_arr = $wp_query->tax_query->queries; |
|
| 642 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
| 643 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
|
|
| 644 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + if (!empty($taxonomies)) {
|
|
| 648 | + foreach (geodir_get_posttypes() as $pt) {
|
|
| 649 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 650 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 651 | + $post_type[] = $pt; |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + if (!empty($post_type)) |
|
| 656 | + return $post_type[0]; |
|
| 657 | + else |
|
| 658 | + return false; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 662 | - /** |
|
| 663 | - * Custom taxonomy walker function. |
|
| 664 | - * |
|
| 665 | - * @since 1.0.0 |
|
| 666 | - * @package GeoDirectory |
|
| 667 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 668 | - * @param int $cat_parent The parent term ID. |
|
| 669 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 670 | - * @param int $pading CSS padding in pixels. |
|
| 671 | - * @return string|void taxonomy HTML. |
|
| 672 | - */ |
|
| 673 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 674 | - {
|
|
| 675 | - global $cat_display, $post_cat, $exclude_cats; |
|
| 676 | - |
|
| 677 | - $search_terms = trim($post_cat, ","); |
|
| 678 | - |
|
| 679 | - $search_terms = explode(",", $search_terms);
|
|
| 680 | - |
|
| 681 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 682 | - |
|
| 683 | - $display = ''; |
|
| 684 | - $onchange = ''; |
|
| 685 | - $term_check = ''; |
|
| 686 | - $main_list_class = ''; |
|
| 687 | - $out = ''; |
|
| 688 | - //If there are terms, start displaying |
|
| 689 | - if (count($cat_terms) > 0) {
|
|
| 690 | - //Displaying as a list |
|
| 691 | - $p = $pading * 20; |
|
| 692 | - $pading++; |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 696 | - if ($cat_parent == 0) {
|
|
| 697 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 698 | - $main_list_class = 'class="main_list_selecter"'; |
|
| 699 | - } else {
|
|
| 700 | - //$display = 'display:none'; |
|
| 701 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
| 702 | - } |
|
| 703 | - } |
|
| 662 | + /** |
|
| 663 | + * Custom taxonomy walker function. |
|
| 664 | + * |
|
| 665 | + * @since 1.0.0 |
|
| 666 | + * @package GeoDirectory |
|
| 667 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 668 | + * @param int $cat_parent The parent term ID. |
|
| 669 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
| 670 | + * @param int $pading CSS padding in pixels. |
|
| 671 | + * @return string|void taxonomy HTML. |
|
| 672 | + */ |
|
| 673 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
| 674 | + {
|
|
| 675 | + global $cat_display, $post_cat, $exclude_cats; |
|
| 676 | + |
|
| 677 | + $search_terms = trim($post_cat, ","); |
|
| 678 | + |
|
| 679 | + $search_terms = explode(",", $search_terms);
|
|
| 680 | + |
|
| 681 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
|
|
| 682 | + |
|
| 683 | + $display = ''; |
|
| 684 | + $onchange = ''; |
|
| 685 | + $term_check = ''; |
|
| 686 | + $main_list_class = ''; |
|
| 687 | + $out = ''; |
|
| 688 | + //If there are terms, start displaying |
|
| 689 | + if (count($cat_terms) > 0) {
|
|
| 690 | + //Displaying as a list |
|
| 691 | + $p = $pading * 20; |
|
| 692 | + $pading++; |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
|
|
| 696 | + if ($cat_parent == 0) {
|
|
| 697 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
| 698 | + $main_list_class = 'class="main_list_selecter"'; |
|
| 699 | + } else {
|
|
| 700 | + //$display = 'display:none'; |
|
| 701 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 706 | - $p = 0; |
|
| 707 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 708 | - } |
|
| 705 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') {
|
|
| 706 | + $p = 0; |
|
| 707 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 708 | + } |
|
| 709 | 709 | |
| 710 | - foreach ($cat_terms as $cat_term) {
|
|
| 710 | + foreach ($cat_terms as $cat_term) {
|
|
| 711 | 711 | |
| 712 | - $checked = ''; |
|
| 712 | + $checked = ''; |
|
| 713 | 713 | |
| 714 | - if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 715 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 716 | - $checked = 'selected="selected"'; |
|
| 717 | - else |
|
| 718 | - $checked = 'checked="checked"'; |
|
| 719 | - } |
|
| 714 | + if (in_array($cat_term->term_id, $search_terms)) {
|
|
| 715 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 716 | + $checked = 'selected="selected"'; |
|
| 717 | + else |
|
| 718 | + $checked = 'checked="checked"'; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - if ($cat_display == 'radio') |
|
| 722 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
| 723 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 724 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
| 721 | + if ($cat_display == 'radio') |
|
| 722 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
| 723 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 724 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
| 725 | 725 | |
| 726 | - else {
|
|
| 727 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
| 728 | - } |
|
| 726 | + else {
|
|
| 727 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | - // Call recurson to print sub cats |
|
| 731 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 730 | + // Call recurson to print sub cats |
|
| 731 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
| 732 | 732 | |
| 733 | - } |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 736 | - $out .= '</div>'; |
|
| 735 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 736 | + $out .= '</div>'; |
|
| 737 | 737 | |
| 738 | - return $out; |
|
| 739 | - } |
|
| 740 | - return; |
|
| 741 | - } |
|
| 738 | + return $out; |
|
| 739 | + } |
|
| 740 | + return; |
|
| 741 | + } |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | if (!function_exists('geodir_custom_taxonomy_walker2')) {
|
| 745 | - /** |
|
| 746 | - * Custom taxonomy walker function. |
|
| 747 | - * |
|
| 748 | - * @since 1.0.0 |
|
| 749 | - * @package GeoDirectory |
|
| 750 | - * @global object $post WordPress Post object. |
|
| 751 | - * @global object $gd_session GeoDirectory Session object. |
|
| 752 | - * @param string $cat_taxonomy The taxonomy name. |
|
| 753 | - * @param string $cat_limit Number of categories to display. |
|
| 754 | - */ |
|
| 755 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 756 | - {
|
|
| 757 | - $post_category = ''; |
|
| 758 | - $post_category_str = ''; |
|
| 759 | - global $exclude_cats, $gd_session; |
|
| 760 | - |
|
| 761 | - $cat_exclude = ''; |
|
| 762 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 763 | - $cat_exclude = serialize($exclude_cats); |
|
| 764 | - |
|
| 765 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 766 | - $post = (object)$gd_session->get('listing');
|
|
| 767 | - |
|
| 768 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 769 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 770 | - |
|
| 771 | - $post_categories = $post->post_category_str; |
|
| 772 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 773 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 774 | - |
|
| 775 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 776 | - global $post; |
|
| 777 | - |
|
| 778 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 779 | - if (empty($post_category) && isset($post->$cat_taxonomy)) {
|
|
| 780 | - $post_category = $post->$cat_taxonomy; |
|
| 781 | - } |
|
| 745 | + /** |
|
| 746 | + * Custom taxonomy walker function. |
|
| 747 | + * |
|
| 748 | + * @since 1.0.0 |
|
| 749 | + * @package GeoDirectory |
|
| 750 | + * @global object $post WordPress Post object. |
|
| 751 | + * @global object $gd_session GeoDirectory Session object. |
|
| 752 | + * @param string $cat_taxonomy The taxonomy name. |
|
| 753 | + * @param string $cat_limit Number of categories to display. |
|
| 754 | + */ |
|
| 755 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
| 756 | + {
|
|
| 757 | + $post_category = ''; |
|
| 758 | + $post_category_str = ''; |
|
| 759 | + global $exclude_cats, $gd_session; |
|
| 760 | + |
|
| 761 | + $cat_exclude = ''; |
|
| 762 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 763 | + $cat_exclude = serialize($exclude_cats); |
|
| 764 | + |
|
| 765 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 766 | + $post = (object)$gd_session->get('listing');
|
|
| 767 | + |
|
| 768 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 769 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 770 | + |
|
| 771 | + $post_categories = $post->post_category_str; |
|
| 772 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 773 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 774 | + |
|
| 775 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
|
| 776 | + global $post; |
|
| 777 | + |
|
| 778 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
| 779 | + if (empty($post_category) && isset($post->$cat_taxonomy)) {
|
|
| 780 | + $post_category = $post->$cat_taxonomy; |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 783 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
| 784 | 784 | |
| 785 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 786 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 787 | - if (is_numeric($cat_part)) {
|
|
| 788 | - $cat_part_arr[] = $cat_part; |
|
| 789 | - } |
|
| 790 | - } |
|
| 791 | - if (is_array($cat_part_arr)) {
|
|
| 792 | - $post_category = implode(',', $cat_part_arr);
|
|
| 793 | - } |
|
| 794 | - } |
|
| 785 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 786 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
|
|
| 787 | + if (is_numeric($cat_part)) {
|
|
| 788 | + $cat_part_arr[] = $cat_part; |
|
| 789 | + } |
|
| 790 | + } |
|
| 791 | + if (is_array($cat_part_arr)) {
|
|
| 792 | + $post_category = implode(',', $cat_part_arr);
|
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | 795 | |
| 796 | - if (!empty($post_category)) {
|
|
| 797 | - $cat1 = array_filter(explode(',', $post_category));
|
|
| 798 | - $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 796 | + if (!empty($post_category)) {
|
|
| 797 | + $cat1 = array_filter(explode(',', $post_category));
|
|
| 798 | + $post_category = ',' . implode(',', $cat1) . ',';
|
|
| 799 | 799 | |
| 800 | - } |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 802 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
|
|
| 803 | 803 | |
| 804 | - $post_category_upd = explode(',', $post_category);
|
|
| 805 | - $post_category_change = ''; |
|
| 806 | - foreach ($post_category_upd as $cat) {
|
|
| 804 | + $post_category_upd = explode(',', $post_category);
|
|
| 805 | + $post_category_change = ''; |
|
| 806 | + foreach ($post_category_upd as $cat) {
|
|
| 807 | 807 | |
| 808 | - if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 809 | - $post_category_change .= ',' . $cat; |
|
| 810 | - } |
|
| 811 | - } |
|
| 812 | - $post_category = $post_category_change; |
|
| 813 | - } |
|
| 808 | + if (!in_array($cat, $exclude_cats) && $cat != '') {
|
|
| 809 | + $post_category_change .= ',' . $cat; |
|
| 810 | + } |
|
| 811 | + } |
|
| 812 | + $post_category = $post_category_change; |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | 815 | |
| 816 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 817 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 818 | - } |
|
| 819 | - } |
|
| 816 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 817 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 818 | + } |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 821 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
| 822 | 822 | |
| 823 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 823 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
| 824 | 824 | |
| 825 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 825 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
| 826 | 826 | |
| 827 | 827 | |
| 828 | - ?> |
|
| 828 | + ?> |
|
| 829 | 829 | <div class="cat_sublist"> |
| 830 | 830 | <?php |
| 831 | 831 | |
| 832 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 832 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
| 833 | 833 | |
| 834 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 834 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
|
|
| 835 | 835 | |
| 836 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 837 | - } |
|
| 838 | - ?> |
|
| 836 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
| 837 | + } |
|
| 838 | + ?> |
|
| 839 | 839 | </div> |
| 840 | 840 | <script type="text/javascript"> |
| 841 | 841 | |
@@ -958,22 +958,22 @@ discard block |
||
| 958 | 958 | |
| 959 | 959 | </script> |
| 960 | 960 | <?php |
| 961 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 962 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 963 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 964 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 965 | - $style = "display:none;"; |
|
| 966 | - } |
|
| 967 | - ?> |
|
| 961 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
|
| 962 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
| 963 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 964 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 965 | + $style = "display:none;"; |
|
| 966 | + } |
|
| 967 | + ?> |
|
| 968 | 968 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
| 969 | - echo $style; |
|
| 970 | - }?> "> |
|
| 969 | + echo $style; |
|
| 970 | + }?> "> |
|
| 971 | 971 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
| 972 | - ?> |
|
| 972 | + ?> |
|
| 973 | 973 | </div> |
| 974 | 974 | <?php |
| 975 | 975 | |
| 976 | - } |
|
| 976 | + } |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -990,23 +990,23 @@ discard block |
||
| 990 | 990 | */ |
| 991 | 991 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
| 992 | 992 | {
|
| 993 | - global $exclude_cats; |
|
| 993 | + global $exclude_cats; |
|
| 994 | 994 | |
| 995 | - if ($exclude != '') {
|
|
| 996 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 995 | + if ($exclude != '') {
|
|
| 996 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
| 997 | 997 | |
| 998 | - if(is_array( $exclude_cats)){
|
|
| 999 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1000 | - }else{
|
|
| 1001 | - $exclude_cats = intval($exclude_cats); |
|
| 1002 | - } |
|
| 998 | + if(is_array( $exclude_cats)){
|
|
| 999 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
| 1000 | + }else{
|
|
| 1001 | + $exclude_cats = intval($exclude_cats); |
|
| 1002 | + } |
|
| 1003 | 1003 | |
| 1004 | - } |
|
| 1004 | + } |
|
| 1005 | 1005 | |
| 1006 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1007 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1008 | - ) {
|
|
| 1009 | - ?> |
|
| 1006 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
| 1007 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
| 1008 | + ) {
|
|
| 1009 | + ?> |
|
| 1010 | 1010 | |
| 1011 | 1011 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
| 1012 | 1012 | |
@@ -1035,8 +1035,8 @@ discard block |
||
| 1035 | 1035 | |
| 1036 | 1036 | <br/> |
| 1037 | 1037 | <?php |
| 1038 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1039 | - if (!empty($cat_terms)) { ?>
|
|
| 1038 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1039 | + if (!empty($cat_terms)) { ?>
|
|
| 1040 | 1040 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
|
| 1041 | 1041 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
| 1042 | 1042 | <?php } ?> |
@@ -1058,53 +1058,53 @@ discard block |
||
| 1058 | 1058 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
| 1059 | 1059 | {
|
| 1060 | 1060 | |
| 1061 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1062 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1063 | - $post_cat_array = explode("#", $post_cat_str);
|
|
| 1064 | - if (is_array($post_cat_array)) {
|
|
| 1065 | - $post_cat_array = array_unique( $post_cat_array ); |
|
| 1061 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
|
|
| 1062 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
| 1063 | + $post_cat_array = explode("#", $post_cat_str);
|
|
| 1064 | + if (is_array($post_cat_array)) {
|
|
| 1065 | + $post_cat_array = array_unique( $post_cat_array ); |
|
| 1066 | 1066 | |
| 1067 | 1067 | foreach ($post_cat_array as $post_cat_html) {
|
| 1068 | 1068 | |
| 1069 | - $post_cat_info = explode(":", $post_cat_html);
|
|
| 1070 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1069 | + $post_cat_info = explode(":", $post_cat_html);
|
|
| 1070 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1071 | 1071 | |
| 1072 | - if (!empty($post_maincat_str)) {
|
|
| 1073 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1074 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1075 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1076 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1077 | - } |
|
| 1078 | - $post_sub_catid = ''; |
|
| 1079 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1080 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1081 | - } |
|
| 1072 | + if (!empty($post_maincat_str)) {
|
|
| 1073 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1074 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1075 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1076 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1077 | + } |
|
| 1078 | + $post_sub_catid = ''; |
|
| 1079 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1080 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1081 | + } |
|
| 1082 | 1082 | |
| 1083 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1083 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1084 | 1084 | |
| 1085 | - } |
|
| 1086 | - } else {
|
|
| 1085 | + } |
|
| 1086 | + } else {
|
|
| 1087 | 1087 | |
| 1088 | - $post_cat_info = explode(":", $post_cat_str);
|
|
| 1089 | - $post_maincat_str = $post_cat_info[0]; |
|
| 1088 | + $post_cat_info = explode(":", $post_cat_str);
|
|
| 1089 | + $post_maincat_str = $post_cat_info[0]; |
|
| 1090 | 1090 | |
| 1091 | - $post_sub_catid = ''; |
|
| 1091 | + $post_sub_catid = ''; |
|
| 1092 | 1092 | |
| 1093 | - if (!empty($post_maincat_str)) {
|
|
| 1094 | - $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1095 | - $post_maincat_id = $post_maincat_info[0]; |
|
| 1096 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1097 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1098 | - } |
|
| 1093 | + if (!empty($post_maincat_str)) {
|
|
| 1094 | + $post_maincat_info = explode(",", $post_maincat_str);
|
|
| 1095 | + $post_maincat_id = $post_maincat_info[0]; |
|
| 1096 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
| 1097 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1101 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1102 | - } |
|
| 1100 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
|
|
| 1101 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
| 1102 | + } |
|
| 1103 | 1103 | |
| 1104 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1104 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
| 1105 | 1105 | |
| 1106 | - } |
|
| 1107 | - } |
|
| 1106 | + } |
|
| 1107 | + } |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | /** |
@@ -1118,35 +1118,35 @@ discard block |
||
| 1118 | 1118 | */ |
| 1119 | 1119 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
| 1120 | 1120 | {
|
| 1121 | - global $exclude_cats; |
|
| 1121 | + global $exclude_cats; |
|
| 1122 | 1122 | |
| 1123 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1123 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
|
|
| 1124 | 1124 | |
| 1125 | - if (!empty($cat_terms)) {
|
|
| 1126 | - $onchange = ''; |
|
| 1127 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1125 | + if (!empty($cat_terms)) {
|
|
| 1126 | + $onchange = ''; |
|
| 1127 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
| 1128 | 1128 | |
| 1129 | - $option_selected = ''; |
|
| 1130 | - if (!$selected) |
|
| 1131 | - $option_slected = ' selected="selected" '; |
|
| 1129 | + $option_selected = ''; |
|
| 1130 | + if (!$selected) |
|
| 1131 | + $option_slected = ' selected="selected" '; |
|
| 1132 | 1132 | |
| 1133 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1133 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
| 1134 | 1134 | |
| 1135 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1135 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 1136 | 1136 | |
| 1137 | - foreach ($cat_terms as $cat_term) {
|
|
| 1138 | - $option_selected = ''; |
|
| 1139 | - if ($selected == $cat_term->term_id) |
|
| 1140 | - $option_selected = ' selected="selected" '; |
|
| 1137 | + foreach ($cat_terms as $cat_term) {
|
|
| 1138 | + $option_selected = ''; |
|
| 1139 | + if ($selected == $cat_term->term_id) |
|
| 1140 | + $option_selected = ' selected="selected" '; |
|
| 1141 | 1141 | |
| 1142 | - // Count child terms |
|
| 1143 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1144 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1142 | + // Count child terms |
|
| 1143 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
| 1144 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
| 1145 | 1145 | |
| 1146 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>'; |
|
| 1147 | - } |
|
| 1148 | - echo '</select>'; |
|
| 1149 | - } |
|
| 1146 | + echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>'; |
|
| 1147 | + } |
|
| 1148 | + echo '</select>'; |
|
| 1149 | + } |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
@@ -1162,28 +1162,28 @@ discard block |
||
| 1162 | 1162 | */ |
| 1163 | 1163 | function geodir_custom_update_messages($messages) |
| 1164 | 1164 | {
|
| 1165 | - global $post, $post_ID; |
|
| 1166 | - |
|
| 1167 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1168 | - |
|
| 1169 | - foreach ($post_types as $post_type => $post_object) {
|
|
| 1170 | - |
|
| 1171 | - $messages[$post_type] = array( |
|
| 1172 | - 0 => '', // Unused. Messages start at index 1. |
|
| 1173 | - 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1174 | - 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1175 | - 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1176 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1177 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1178 | - 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1179 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1180 | - 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1181 | - 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1182 | - 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1183 | - ); |
|
| 1184 | - } |
|
| 1185 | - |
|
| 1186 | - return $messages; |
|
| 1165 | + global $post, $post_ID; |
|
| 1166 | + |
|
| 1167 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
|
|
| 1168 | + |
|
| 1169 | + foreach ($post_types as $post_type => $post_object) {
|
|
| 1170 | + |
|
| 1171 | + $messages[$post_type] = array( |
|
| 1172 | + 0 => '', // Unused. Messages start at index 1. |
|
| 1173 | + 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1174 | + 2 => __('Custom field updated.', 'geodirectory'),
|
|
| 1175 | + 3 => __('Custom field deleted.', 'geodirectory'),
|
|
| 1176 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1177 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
|
|
| 1178 | + 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1179 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
|
|
| 1180 | + 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1181 | + 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
|
|
| 1182 | + 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
|
|
| 1183 | + ); |
|
| 1184 | + } |
|
| 1185 | + |
|
| 1186 | + return $messages; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | |
@@ -1198,181 +1198,181 @@ discard block |
||
| 1198 | 1198 | function geodir_register_defaults() |
| 1199 | 1199 | {
|
| 1200 | 1200 | |
| 1201 | - global $wpdb; |
|
| 1202 | - |
|
| 1203 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1204 | - |
|
| 1205 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1206 | - $listing_slug = 'places'; |
|
| 1207 | - |
|
| 1208 | - /** |
|
| 1209 | - * Taxonomies |
|
| 1210 | - **/ |
|
| 1211 | - //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1212 | - {
|
|
| 1213 | - |
|
| 1214 | - $gd_placetags = array(); |
|
| 1215 | - $gd_placetags['object_type'] = 'gd_place'; |
|
| 1216 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1217 | - $gd_placetags['args'] = array( |
|
| 1218 | - 'public' => true, |
|
| 1219 | - 'hierarchical' => false, |
|
| 1220 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1221 | - 'query_var' => true, |
|
| 1222 | - |
|
| 1223 | - 'labels' => array( |
|
| 1224 | - 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1225 | - 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1226 | - 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1227 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1228 | - 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1229 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1230 | - 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1231 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1232 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1233 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1234 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1235 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1236 | - ), |
|
| 1237 | - ); |
|
| 1238 | - |
|
| 1239 | - |
|
| 1240 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1241 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1242 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1243 | - |
|
| 1244 | - |
|
| 1245 | - // Update post types and delete tmp options |
|
| 1246 | - flush_rewrite_rules(); |
|
| 1247 | - |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1251 | - {
|
|
| 1252 | - |
|
| 1253 | - $gd_placecategory = array(); |
|
| 1254 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1255 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1256 | - $gd_placecategory['args'] = array( |
|
| 1257 | - 'public' => true, |
|
| 1258 | - 'hierarchical' => true, |
|
| 1259 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1260 | - 'query_var' => true, |
|
| 1261 | - 'labels' => array( |
|
| 1262 | - 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1263 | - 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1264 | - 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1265 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1266 | - 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1267 | - 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1268 | - 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1269 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1270 | - 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1271 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1272 | - ), |
|
| 1273 | - ); |
|
| 1274 | - |
|
| 1275 | - |
|
| 1276 | - $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1277 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1278 | - update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1279 | - |
|
| 1280 | - |
|
| 1281 | - flush_rewrite_rules(); |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - /** |
|
| 1285 | - * Post Types |
|
| 1286 | - **/ |
|
| 1287 | - |
|
| 1288 | - //if ( ! post_type_exists('gd_place') )
|
|
| 1289 | - {
|
|
| 1290 | - |
|
| 1291 | - $labels = array( |
|
| 1292 | - 'name' => __('Places', 'geodirectory'),
|
|
| 1293 | - 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1294 | - 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1295 | - 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1296 | - 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1297 | - 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1298 | - 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1299 | - 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1300 | - 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1301 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1302 | - |
|
| 1303 | - $place_default = array( |
|
| 1304 | - 'labels' => $labels, |
|
| 1305 | - 'can_export' => true, |
|
| 1306 | - 'capability_type' => 'post', |
|
| 1307 | - 'description' => 'Place post type.', |
|
| 1308 | - 'has_archive' => $listing_slug, |
|
| 1309 | - 'hierarchical' => false, |
|
| 1310 | - 'map_meta_cap' => true, |
|
| 1311 | - 'menu_icon' => $menu_icon, |
|
| 1312 | - 'public' => true, |
|
| 1313 | - 'query_var' => true, |
|
| 1314 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true),
|
|
| 1315 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1316 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1317 | - |
|
| 1318 | - //Update custom post types |
|
| 1319 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 1320 | - $geodir_post_types['gd_place'] = $place_default; |
|
| 1321 | - update_option('geodir_post_types', $geodir_post_types);
|
|
| 1322 | - |
|
| 1323 | - // Update post types and delete tmp options |
|
| 1324 | - flush_rewrite_rules(); |
|
| 1325 | - } |
|
| 1326 | - |
|
| 1327 | - |
|
| 1328 | - geodir_register_taxonomies(); |
|
| 1329 | - geodir_register_post_types(); |
|
| 1330 | - |
|
| 1331 | - //die; |
|
| 1201 | + global $wpdb; |
|
| 1202 | + |
|
| 1203 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
| 1204 | + |
|
| 1205 | + if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1206 | + $listing_slug = 'places'; |
|
| 1207 | + |
|
| 1208 | + /** |
|
| 1209 | + * Taxonomies |
|
| 1210 | + **/ |
|
| 1211 | + //if ( ! taxonomy_exists('gd_place_tags') )
|
|
| 1212 | + {
|
|
| 1213 | + |
|
| 1214 | + $gd_placetags = array(); |
|
| 1215 | + $gd_placetags['object_type'] = 'gd_place'; |
|
| 1216 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
| 1217 | + $gd_placetags['args'] = array( |
|
| 1218 | + 'public' => true, |
|
| 1219 | + 'hierarchical' => false, |
|
| 1220 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
|
|
| 1221 | + 'query_var' => true, |
|
| 1222 | + |
|
| 1223 | + 'labels' => array( |
|
| 1224 | + 'name' => __('Place Tags', 'geodirectory'),
|
|
| 1225 | + 'singular_name' => __('Place Tag', 'geodirectory'),
|
|
| 1226 | + 'search_items' => __('Search Place Tags', 'geodirectory'),
|
|
| 1227 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'),
|
|
| 1228 | + 'all_items' => __('All Place Tags', 'geodirectory'),
|
|
| 1229 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'),
|
|
| 1230 | + 'update_item' => __('Update Place Tag', 'geodirectory'),
|
|
| 1231 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'),
|
|
| 1232 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'),
|
|
| 1233 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
|
|
| 1234 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
|
|
| 1235 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
|
|
| 1236 | + ), |
|
| 1237 | + ); |
|
| 1238 | + |
|
| 1239 | + |
|
| 1240 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1241 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
| 1242 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1243 | + |
|
| 1244 | + |
|
| 1245 | + // Update post types and delete tmp options |
|
| 1246 | + flush_rewrite_rules(); |
|
| 1247 | + |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + //if ( ! taxonomy_exists('gd_placecategory') )
|
|
| 1251 | + {
|
|
| 1252 | + |
|
| 1253 | + $gd_placecategory = array(); |
|
| 1254 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
| 1255 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
| 1256 | + $gd_placecategory['args'] = array( |
|
| 1257 | + 'public' => true, |
|
| 1258 | + 'hierarchical' => true, |
|
| 1259 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
|
|
| 1260 | + 'query_var' => true, |
|
| 1261 | + 'labels' => array( |
|
| 1262 | + 'name' => __('Place Categories', 'geodirectory'),
|
|
| 1263 | + 'singular_name' => __('Place Category', 'geodirectory'),
|
|
| 1264 | + 'search_items' => __('Search Place Categories', 'geodirectory'),
|
|
| 1265 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'),
|
|
| 1266 | + 'all_items' => __('All Place Categories', 'geodirectory'),
|
|
| 1267 | + 'edit_item' => __('Edit Place Category', 'geodirectory'),
|
|
| 1268 | + 'update_item' => __('Update Place Category', 'geodirectory'),
|
|
| 1269 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'),
|
|
| 1270 | + 'new_item_name' => __('New Place Category', 'geodirectory'),
|
|
| 1271 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
|
|
| 1272 | + ), |
|
| 1273 | + ); |
|
| 1274 | + |
|
| 1275 | + |
|
| 1276 | + $geodir_taxonomies = get_option('geodir_taxonomies');
|
|
| 1277 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
| 1278 | + update_option('geodir_taxonomies', $geodir_taxonomies);
|
|
| 1279 | + |
|
| 1280 | + |
|
| 1281 | + flush_rewrite_rules(); |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + /** |
|
| 1285 | + * Post Types |
|
| 1286 | + **/ |
|
| 1287 | + |
|
| 1288 | + //if ( ! post_type_exists('gd_place') )
|
|
| 1289 | + {
|
|
| 1290 | + |
|
| 1291 | + $labels = array( |
|
| 1292 | + 'name' => __('Places', 'geodirectory'),
|
|
| 1293 | + 'singular_name' => __('Place', 'geodirectory'),
|
|
| 1294 | + 'add_new' => __('Add New', 'geodirectory'),
|
|
| 1295 | + 'add_new_item' => __('Add New Place', 'geodirectory'),
|
|
| 1296 | + 'edit_item' => __('Edit Place', 'geodirectory'),
|
|
| 1297 | + 'new_item' => __('New Place', 'geodirectory'),
|
|
| 1298 | + 'view_item' => __('View Place', 'geodirectory'),
|
|
| 1299 | + 'search_items' => __('Search Places', 'geodirectory'),
|
|
| 1300 | + 'not_found' => __('No Place Found', 'geodirectory'),
|
|
| 1301 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
|
|
| 1302 | + |
|
| 1303 | + $place_default = array( |
|
| 1304 | + 'labels' => $labels, |
|
| 1305 | + 'can_export' => true, |
|
| 1306 | + 'capability_type' => 'post', |
|
| 1307 | + 'description' => 'Place post type.', |
|
| 1308 | + 'has_archive' => $listing_slug, |
|
| 1309 | + 'hierarchical' => false, |
|
| 1310 | + 'map_meta_cap' => true, |
|
| 1311 | + 'menu_icon' => $menu_icon, |
|
| 1312 | + 'public' => true, |
|
| 1313 | + 'query_var' => true, |
|
| 1314 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true),
|
|
| 1315 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
|
|
| 1316 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
|
|
| 1317 | + |
|
| 1318 | + //Update custom post types |
|
| 1319 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 1320 | + $geodir_post_types['gd_place'] = $place_default; |
|
| 1321 | + update_option('geodir_post_types', $geodir_post_types);
|
|
| 1322 | + |
|
| 1323 | + // Update post types and delete tmp options |
|
| 1324 | + flush_rewrite_rules(); |
|
| 1325 | + } |
|
| 1326 | + |
|
| 1327 | + |
|
| 1328 | + geodir_register_taxonomies(); |
|
| 1329 | + geodir_register_post_types(); |
|
| 1330 | + |
|
| 1331 | + //die; |
|
| 1332 | 1332 | |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | $gd_wpml_get_languages = ""; |
| 1336 | 1336 | function gd_wpml_get_lang_from_url($url){
|
| 1337 | 1337 | |
| 1338 | - global $gd_wpml_get_languages; |
|
| 1339 | - if(isset($_REQUEST['lang']) && $_REQUEST['lang']){return $_REQUEST['lang'];}
|
|
| 1338 | + global $gd_wpml_get_languages; |
|
| 1339 | + if(isset($_REQUEST['lang']) && $_REQUEST['lang']){return $_REQUEST['lang'];}
|
|
| 1340 | 1340 | |
| 1341 | 1341 | |
| 1342 | - // |
|
| 1343 | - $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1344 | - $site_url = str_replace(array("http://","https://"),"",get_bloginfo('url'));
|
|
| 1342 | + // |
|
| 1343 | + $url = str_replace(array("http://","https://"),"",$url);
|
|
| 1344 | + $site_url = str_replace(array("http://","https://"),"",get_bloginfo('url'));
|
|
| 1345 | 1345 | |
| 1346 | - $url = str_replace($site_url,"",$url); |
|
| 1346 | + $url = str_replace($site_url,"",$url); |
|
| 1347 | 1347 | |
| 1348 | 1348 | |
| 1349 | - $segments = explode('/', trim($url, '/'));
|
|
| 1349 | + $segments = explode('/', trim($url, '/'));
|
|
| 1350 | 1350 | |
| 1351 | - //print_r( $segments); |
|
| 1352 | - if($gd_wpml_get_languages){
|
|
| 1353 | - $langs = $gd_wpml_get_languages; |
|
| 1354 | - }else{
|
|
| 1355 | - global $sitepress; |
|
| 1356 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1357 | - } |
|
| 1351 | + //print_r( $segments); |
|
| 1352 | + if($gd_wpml_get_languages){
|
|
| 1353 | + $langs = $gd_wpml_get_languages; |
|
| 1354 | + }else{
|
|
| 1355 | + global $sitepress; |
|
| 1356 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
| 1357 | + } |
|
| 1358 | 1358 | |
| 1359 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1360 | - return $segments[0]; |
|
| 1361 | - } |
|
| 1359 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
|
|
| 1360 | + return $segments[0]; |
|
| 1361 | + } |
|
| 1362 | 1362 | |
| 1363 | - return false; |
|
| 1363 | + return false; |
|
| 1364 | 1364 | |
| 1365 | 1365 | |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | function gd_wpml_slug_translation_turned_on($post_type) {
|
| 1369 | 1369 | |
| 1370 | - global $sitepress; |
|
| 1371 | - $settings = $sitepress->get_settings(); |
|
| 1372 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1373 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1374 | - && isset($settings['posts_slug_translation']['on']) |
|
| 1375 | - && $settings['posts_slug_translation']['on']; |
|
| 1370 | + global $sitepress; |
|
| 1371 | + $settings = $sitepress->get_settings(); |
|
| 1372 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
| 1373 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
| 1374 | + && isset($settings['posts_slug_translation']['on']) |
|
| 1375 | + && $settings['posts_slug_translation']['on']; |
|
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | |
@@ -1397,150 +1397,150 @@ discard block |
||
| 1397 | 1397 | */ |
| 1398 | 1398 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
| 1399 | 1399 | {
|
| 1400 | - //echo $post_link."<br />".$sample ; |
|
| 1400 | + //echo $post_link."<br />".$sample ; |
|
| 1401 | 1401 | |
| 1402 | 1402 | |
| 1403 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1404 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1405 | - } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1406 | - return $post_link; |
|
| 1407 | - } else {
|
|
| 1408 | - $orig_post = $post; |
|
| 1409 | - $post = $post_obj; |
|
| 1410 | - } |
|
| 1403 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
| 1404 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
|
|
| 1405 | + } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
|
|
| 1406 | + return $post_link; |
|
| 1407 | + } else {
|
|
| 1408 | + $orig_post = $post; |
|
| 1409 | + $post = $post_obj; |
|
| 1410 | + } |
|
| 1411 | 1411 | |
| 1412 | - if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1412 | + if (in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 1413 | 1413 | |
| 1414 | 1414 | |
| 1415 | - $post_types = get_option('geodir_post_types');
|
|
| 1416 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1415 | + $post_types = get_option('geodir_post_types');
|
|
| 1416 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
| 1417 | 1417 | |
| 1418 | - // Alter the CPT slug if WPML is set to do so |
|
| 1419 | - if(function_exists('icl_object_id')){
|
|
| 1420 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1418 | + // Alter the CPT slug if WPML is set to do so |
|
| 1419 | + if(function_exists('icl_object_id')){
|
|
| 1420 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
|
|
| 1421 | 1421 | |
| 1422 | - $org_slug = $slug; |
|
| 1423 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1424 | - $slug, |
|
| 1425 | - 'WordPress', |
|
| 1426 | - 'URL slug: ' . $slug, |
|
| 1427 | - $language_code); |
|
| 1422 | + $org_slug = $slug; |
|
| 1423 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1424 | + $slug, |
|
| 1425 | + 'WordPress', |
|
| 1426 | + 'URL slug: ' . $slug, |
|
| 1427 | + $language_code); |
|
| 1428 | 1428 | |
| 1429 | - if(!$slug){$slug = $org_slug;}
|
|
| 1429 | + if(!$slug){$slug = $org_slug;}
|
|
| 1430 | 1430 | |
| 1431 | - } |
|
| 1432 | - } |
|
| 1431 | + } |
|
| 1432 | + } |
|
| 1433 | 1433 | |
| 1434 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1435 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1436 | - } |
|
| 1434 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1435 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 1436 | + } |
|
| 1437 | 1437 | |
| 1438 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1439 | - $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1438 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
| 1439 | + $site_url = trailingslashit(get_bloginfo('url'));
|
|
| 1440 | 1440 | |
| 1441 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1442 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1443 | - } |
|
| 1444 | - |
|
| 1445 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1446 | - if ($fix_url) {
|
|
| 1447 | - $post_link = str_replace($site_url, '', $post_link); |
|
| 1448 | - } |
|
| 1441 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 1442 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 1443 | + } |
|
| 1444 | + |
|
| 1445 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
| 1446 | + if ($fix_url) {
|
|
| 1447 | + $post_link = str_replace($site_url, '', $post_link); |
|
| 1448 | + } |
|
| 1449 | 1449 | |
| 1450 | - $post_link = trailingslashit( |
|
| 1451 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1452 | - ); |
|
| 1453 | - |
|
| 1454 | - if ($fix_url) {
|
|
| 1455 | - $post_link = $site_url . $post_link; |
|
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - if (isset($comment_post_cache[$post->ID])) {
|
|
| 1459 | - $post = $comment_post_cache[$post->ID]; |
|
| 1460 | - } |
|
| 1461 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1462 | - $post_id = $post->ID; |
|
| 1463 | - if (isset($orig_post)) {
|
|
| 1464 | - $post = $orig_post; |
|
| 1465 | - } |
|
| 1466 | - return $gd_permalink_cache[$post_id]; |
|
| 1467 | - } |
|
| 1450 | + $post_link = trailingslashit( |
|
| 1451 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
| 1452 | + ); |
|
| 1468 | 1453 | |
| 1469 | - if (!isset($post->post_locations)) {
|
|
| 1470 | - $post_type = $post->post_type; |
|
| 1471 | - $ID = $post->ID; |
|
| 1472 | - $post2 = $wpdb->get_row( |
|
| 1473 | - $wpdb->prepare( |
|
| 1474 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1475 | - array($post->ID) |
|
| 1476 | - ) |
|
| 1477 | - ); |
|
| 1454 | + if ($fix_url) {
|
|
| 1455 | + $post_link = $site_url . $post_link; |
|
| 1456 | + } |
|
| 1478 | 1457 | |
| 1479 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1458 | + if (isset($comment_post_cache[$post->ID])) {
|
|
| 1459 | + $post = $comment_post_cache[$post->ID]; |
|
| 1460 | + } |
|
| 1461 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
|
|
| 1462 | + $post_id = $post->ID; |
|
| 1463 | + if (isset($orig_post)) {
|
|
| 1464 | + $post = $orig_post; |
|
| 1465 | + } |
|
| 1466 | + return $gd_permalink_cache[$post_id]; |
|
| 1467 | + } |
|
| 1480 | 1468 | |
| 1481 | - $comment_post_cache[$post->ID] = $post; |
|
| 1482 | - } |
|
| 1469 | + if (!isset($post->post_locations)) {
|
|
| 1470 | + $post_type = $post->post_type; |
|
| 1471 | + $ID = $post->ID; |
|
| 1472 | + $post2 = $wpdb->get_row( |
|
| 1473 | + $wpdb->prepare( |
|
| 1474 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1475 | + array($post->ID) |
|
| 1476 | + ) |
|
| 1477 | + ); |
|
| 1483 | 1478 | |
| 1479 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
| 1484 | 1480 | |
| 1481 | + $comment_post_cache[$post->ID] = $post; |
|
| 1482 | + } |
|
| 1485 | 1483 | |
| 1486 | - if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1487 | 1484 | |
| 1488 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1489 | - $location_request = ''; |
|
| 1490 | 1485 | |
| 1486 | + if (false !== strpos($post_link, '%gd_taxonomy%')) {
|
|
| 1491 | 1487 | |
| 1492 | - if (!empty($post->post_locations)) {
|
|
| 1493 | - $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1494 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1495 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1496 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1497 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1498 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1499 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1500 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1488 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
|
|
| 1489 | + $location_request = ''; |
|
| 1501 | 1490 | |
| 1502 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1503 | - 'region_slug' => $post->region_slug, |
|
| 1504 | - 'city_slug' => $post->city_slug |
|
| 1505 | - ); |
|
| 1506 | 1491 | |
| 1507 | - } else |
|
| 1508 | - $post_location = geodir_get_location(); |
|
| 1492 | + if (!empty($post->post_locations)) {
|
|
| 1493 | + $geodir_arr_locations = explode(',', $post->post_locations);
|
|
| 1494 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1495 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1496 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1497 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1498 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1499 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1500 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1509 | 1501 | |
| 1502 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1503 | + 'region_slug' => $post->region_slug, |
|
| 1504 | + 'city_slug' => $post->city_slug |
|
| 1505 | + ); |
|
| 1510 | 1506 | |
| 1511 | - } else {
|
|
| 1507 | + } else |
|
| 1508 | + $post_location = geodir_get_location(); |
|
| 1512 | 1509 | |
| 1513 | - $post_location_sql = $wpdb->get_results( |
|
| 1514 | - $wpdb->prepare( |
|
| 1515 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1516 | - array($post->ID) |
|
| 1517 | - ) |
|
| 1518 | - ); |
|
| 1519 | - |
|
| 1520 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1521 | - |
|
| 1522 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1523 | - if (count($geodir_arr_locations) == 3) {
|
|
| 1524 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1525 | - $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1526 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1527 | - $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1528 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1529 | - $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1530 | - |
|
| 1531 | - $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1532 | - 'region_slug' => $post->region_slug, |
|
| 1533 | - 'city_slug' => $post->city_slug |
|
| 1534 | - ); |
|
| 1535 | 1510 | |
| 1536 | - } |
|
| 1537 | - } else |
|
| 1538 | - $post_location = geodir_get_location(); |
|
| 1539 | - } |
|
| 1511 | + } else {
|
|
| 1540 | 1512 | |
| 1513 | + $post_location_sql = $wpdb->get_results( |
|
| 1514 | + $wpdb->prepare( |
|
| 1515 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
| 1516 | + array($post->ID) |
|
| 1517 | + ) |
|
| 1518 | + ); |
|
| 1519 | + |
|
| 1520 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
|
|
| 1521 | + |
|
| 1522 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
|
|
| 1523 | + if (count($geodir_arr_locations) == 3) {
|
|
| 1524 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
|
|
| 1525 | + $post->city_slug = str_replace(']', '', $post->city_slug);
|
|
| 1526 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
|
|
| 1527 | + $post->region_slug = str_replace(']', '', $post->region_slug);
|
|
| 1528 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
|
|
| 1529 | + $post->country_slug = str_replace(']', '', $post->country_slug);
|
|
| 1530 | + |
|
| 1531 | + $post_location = (object)array('country_slug' => $post->country_slug,
|
|
| 1532 | + 'region_slug' => $post->region_slug, |
|
| 1533 | + 'city_slug' => $post->city_slug |
|
| 1534 | + ); |
|
| 1535 | + |
|
| 1536 | + } |
|
| 1537 | + } else |
|
| 1538 | + $post_location = geodir_get_location(); |
|
| 1539 | + } |
|
| 1541 | 1540 | |
| 1542 | - if (!empty($post_location)) {
|
|
| 1543 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1541 | + |
|
| 1542 | + if (!empty($post_location)) {
|
|
| 1543 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
| 1544 | 1544 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
| 1545 | 1545 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
| 1546 | 1546 | |
@@ -1558,78 +1558,78 @@ discard block |
||
| 1558 | 1558 | $location_slug[] = $city_slug; |
| 1559 | 1559 | |
| 1560 | 1560 | $location_request .= implode('/', $location_slug) . '/';
|
| 1561 | - } |
|
| 1562 | - } |
|
| 1561 | + } |
|
| 1562 | + } |
|
| 1563 | 1563 | |
| 1564 | - if (get_option('geodir_add_categories_url')) {
|
|
| 1564 | + if (get_option('geodir_add_categories_url')) {
|
|
| 1565 | 1565 | |
| 1566 | - $term_request = ''; |
|
| 1567 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1566 | + $term_request = ''; |
|
| 1567 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
| 1568 | 1568 | |
| 1569 | - $taxonomies = end($taxonomies); |
|
| 1569 | + $taxonomies = end($taxonomies); |
|
| 1570 | 1570 | |
| 1571 | - if (!empty($post->default_category)) {
|
|
| 1572 | - $post_terms = $post->default_category; |
|
| 1573 | - } else {
|
|
| 1574 | - $post_terms = ''; |
|
| 1571 | + if (!empty($post->default_category)) {
|
|
| 1572 | + $post_terms = $post->default_category; |
|
| 1573 | + } else {
|
|
| 1574 | + $post_terms = ''; |
|
| 1575 | 1575 | |
| 1576 | - if (isset($post->$taxonomies)) {
|
|
| 1577 | - $post_terms = explode(",", trim($post->$taxonomies, ","));
|
|
| 1578 | - $post_terms = $post_terms[0]; |
|
| 1579 | - } |
|
| 1576 | + if (isset($post->$taxonomies)) {
|
|
| 1577 | + $post_terms = explode(",", trim($post->$taxonomies, ","));
|
|
| 1578 | + $post_terms = $post_terms[0]; |
|
| 1579 | + } |
|
| 1580 | 1580 | |
| 1581 | - if (!$post_terms) |
|
| 1582 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1581 | + if (!$post_terms) |
|
| 1582 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1583 | 1583 | |
| 1584 | - if (!$post_terms) {
|
|
| 1585 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1584 | + if (!$post_terms) {
|
|
| 1585 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
| 1586 | 1586 | |
| 1587 | - if ($post_terms) {
|
|
| 1588 | - $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1589 | - $post_terms = $post_terms[0]; |
|
| 1590 | - } |
|
| 1591 | - } |
|
| 1592 | - } |
|
| 1587 | + if ($post_terms) {
|
|
| 1588 | + $post_terms = explode(",", trim($post_terms, ","));
|
|
| 1589 | + $post_terms = $post_terms[0]; |
|
| 1590 | + } |
|
| 1591 | + } |
|
| 1592 | + } |
|
| 1593 | 1593 | |
| 1594 | - $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1594 | + $term = get_term_by('id', $post_terms, $taxonomies);
|
|
| 1595 | 1595 | |
| 1596 | - if (!empty($term)) |
|
| 1597 | - $term_request = $term->slug; |
|
| 1598 | - //$term_request = $term->slug.'/'; |
|
| 1599 | - } |
|
| 1596 | + if (!empty($term)) |
|
| 1597 | + $term_request = $term->slug; |
|
| 1598 | + //$term_request = $term->slug.'/'; |
|
| 1599 | + } |
|
| 1600 | 1600 | |
| 1601 | - $request_term = ''; |
|
| 1602 | - $listingurl_separator = ''; |
|
| 1603 | - //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1604 | - $detailurl_separator = ''; |
|
| 1605 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1606 | - $request_term = $location_request; |
|
| 1607 | - //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1608 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1609 | - $request_term .= $term_request; |
|
| 1601 | + $request_term = ''; |
|
| 1602 | + $listingurl_separator = ''; |
|
| 1603 | + //$detailurl_separator = get_option('geodir_detailurl_separator');
|
|
| 1604 | + $detailurl_separator = ''; |
|
| 1605 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
|
|
| 1606 | + $request_term = $location_request; |
|
| 1607 | + //$listingurl_separator = get_option('geodir_listingurl_separator');
|
|
| 1608 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
| 1609 | + $request_term .= $term_request; |
|
| 1610 | 1610 | |
| 1611 | - } else {
|
|
| 1612 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1611 | + } else {
|
|
| 1612 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1613 | 1613 | |
| 1614 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1615 | - } |
|
| 1616 | - $request_term = trim($request_term, '/'); |
|
| 1617 | - if (!empty($request_term)) |
|
| 1618 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1619 | - else |
|
| 1620 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1621 | - //echo $post_link ; |
|
| 1622 | - } |
|
| 1623 | - // temp cache the permalink |
|
| 1624 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1625 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1626 | - } |
|
| 1627 | - } |
|
| 1628 | - if (isset($orig_post)) {
|
|
| 1629 | - $post = $orig_post; |
|
| 1630 | - } |
|
| 1631 | - //echo $post_link ; |
|
| 1632 | - return $post_link; |
|
| 1614 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1615 | + } |
|
| 1616 | + $request_term = trim($request_term, '/'); |
|
| 1617 | + if (!empty($request_term)) |
|
| 1618 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1619 | + else |
|
| 1620 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1621 | + //echo $post_link ; |
|
| 1622 | + } |
|
| 1623 | + // temp cache the permalink |
|
| 1624 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
|
|
| 1625 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
| 1626 | + } |
|
| 1627 | + } |
|
| 1628 | + if (isset($orig_post)) {
|
|
| 1629 | + $post = $orig_post; |
|
| 1630 | + } |
|
| 1631 | + //echo $post_link ; |
|
| 1632 | + return $post_link; |
|
| 1633 | 1633 | |
| 1634 | 1634 | } |
| 1635 | 1635 | |
@@ -1646,103 +1646,103 @@ discard block |
||
| 1646 | 1646 | * @return string The term link. |
| 1647 | 1647 | */ |
| 1648 | 1648 | function geodir_term_link($termlink, $term, $taxonomy) {
|
| 1649 | - $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1649 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1650 | 1650 | |
| 1651 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1652 | - global $geodir_add_location_url, $gd_session; |
|
| 1653 | - $include_location = false; |
|
| 1654 | - $request_term = array(); |
|
| 1651 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
|
|
| 1652 | + global $geodir_add_location_url, $gd_session; |
|
| 1653 | + $include_location = false; |
|
| 1654 | + $request_term = array(); |
|
| 1655 | 1655 | |
| 1656 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1656 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
| 1657 | 1657 | |
| 1658 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1659 | - if ($geodir_add_location_url && get_option('geodir_add_location_url')) {
|
|
| 1660 | - $include_location = true; |
|
| 1661 | - } |
|
| 1662 | - } elseif (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1)
|
|
| 1663 | - $include_location = true; |
|
| 1658 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
|
|
| 1659 | + if ($geodir_add_location_url && get_option('geodir_add_location_url')) {
|
|
| 1660 | + $include_location = true; |
|
| 1661 | + } |
|
| 1662 | + } elseif (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1)
|
|
| 1663 | + $include_location = true; |
|
| 1664 | 1664 | |
| 1665 | - if ($include_location) {
|
|
| 1666 | - global $post; |
|
| 1665 | + if ($include_location) {
|
|
| 1666 | + global $post; |
|
| 1667 | 1667 | |
| 1668 | 1668 | $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
| 1669 | 1669 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 1670 | 1670 | |
| 1671 | 1671 | if(geodir_is_page('detail') && isset($post->country_slug)){
|
| 1672 | - $location_terms = array( |
|
| 1673 | - 'gd_country' => $post->country_slug, |
|
| 1674 | - 'gd_region' => $post->region_slug, |
|
| 1675 | - 'gd_city' => $post->city_slug |
|
| 1676 | - ); |
|
| 1672 | + $location_terms = array( |
|
| 1673 | + 'gd_country' => $post->country_slug, |
|
| 1674 | + 'gd_region' => $post->region_slug, |
|
| 1675 | + 'gd_city' => $post->city_slug |
|
| 1676 | + ); |
|
| 1677 | 1677 | |
| 1678 | 1678 | if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
| 1679 | 1679 | $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
| 1680 | 1680 | } |
| 1681 | - } else {
|
|
| 1682 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1683 | - } |
|
| 1681 | + } else {
|
|
| 1682 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1683 | + } |
|
| 1684 | 1684 | |
| 1685 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1686 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1685 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1686 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
| 1687 | 1687 | |
| 1688 | - if (!empty($location_terms)) {
|
|
| 1688 | + if (!empty($location_terms)) {
|
|
| 1689 | 1689 | |
| 1690 | - $url_separator = '';//get_option('geodir_listingurl_separator');
|
|
| 1690 | + $url_separator = '';//get_option('geodir_listingurl_separator');
|
|
| 1691 | 1691 | |
| 1692 | - if (get_option('permalink_structure') != '') {
|
|
| 1693 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1694 | - $request_term = implode("/", $location_terms);
|
|
| 1695 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1692 | + if (get_option('permalink_structure') != '') {
|
|
| 1693 | + $old_listing_slug = '/' . $listing_slug . '/'; |
|
| 1694 | + $request_term = implode("/", $location_terms);
|
|
| 1695 | + $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
| 1696 | 1696 | |
| 1697 | - $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1698 | - } else {
|
|
| 1699 | - $termlink = geodir_getlink($termlink, $request_term); |
|
| 1700 | - } |
|
| 1701 | - } |
|
| 1702 | - } |
|
| 1697 | + $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
| 1698 | + } else {
|
|
| 1699 | + $termlink = geodir_getlink($termlink, $request_term); |
|
| 1700 | + } |
|
| 1701 | + } |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | - // Alter the CPT slug is WPML is set to do so |
|
| 1705 | - /* we can replace this with the below function |
|
| 1704 | + // Alter the CPT slug is WPML is set to do so |
|
| 1705 | + /* we can replace this with the below function |
|
| 1706 | 1706 | if(function_exists('icl_object_id')){
|
| 1707 | 1707 | global $sitepress; |
| 1708 | 1708 | $post_type = str_replace("category","",$taxonomy);
|
| 1709 | 1709 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
| 1710 | 1710 | }*/ |
| 1711 | 1711 | |
| 1712 | - // Alter the CPT slug if WPML is set to do so |
|
| 1713 | - if(function_exists('icl_object_id')){
|
|
| 1714 | - $post_types = get_option('geodir_post_types');
|
|
| 1715 | - $post_type = str_replace("category","",$taxonomy);
|
|
| 1712 | + // Alter the CPT slug if WPML is set to do so |
|
| 1713 | + if(function_exists('icl_object_id')){
|
|
| 1714 | + $post_types = get_option('geodir_post_types');
|
|
| 1715 | + $post_type = str_replace("category","",$taxonomy);
|
|
| 1716 | 1716 | $post_type = str_replace("_tags","",$post_type);
|
| 1717 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1718 | - if ( gd_wpml_slug_translation_turned_on( $post_type )) {
|
|
| 1717 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1718 | + if ( gd_wpml_slug_translation_turned_on( $post_type )) {
|
|
| 1719 | 1719 | |
| 1720 | - global $sitepress; |
|
| 1721 | - $default_lang = $sitepress->get_default_language(); |
|
| 1722 | - $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1723 | - if(!$language_code ){$language_code = $default_lang;}
|
|
| 1720 | + global $sitepress; |
|
| 1721 | + $default_lang = $sitepress->get_default_language(); |
|
| 1722 | + $language_code = gd_wpml_get_lang_from_url($termlink); |
|
| 1723 | + if(!$language_code ){$language_code = $default_lang;}
|
|
| 1724 | 1724 | |
| 1725 | - $org_slug = $slug; |
|
| 1726 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1727 | - $slug, |
|
| 1728 | - 'WordPress', |
|
| 1729 | - 'URL slug: ' . $slug, |
|
| 1730 | - $language_code); |
|
| 1725 | + $org_slug = $slug; |
|
| 1726 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1727 | + $slug, |
|
| 1728 | + 'WordPress', |
|
| 1729 | + 'URL slug: ' . $slug, |
|
| 1730 | + $language_code); |
|
| 1731 | 1731 | |
| 1732 | 1732 | |
| 1733 | - if(!$slug){$slug = $org_slug;}
|
|
| 1733 | + if(!$slug){$slug = $org_slug;}
|
|
| 1734 | 1734 | |
| 1735 | - $termlink = trailingslashit( |
|
| 1735 | + $termlink = trailingslashit( |
|
| 1736 | 1736 | |
| 1737 | - preg_replace( "/" . preg_quote( $org_slug, "/" ) . "/", $slug ,$termlink, 1 ) |
|
| 1738 | - ); |
|
| 1737 | + preg_replace( "/" . preg_quote( $org_slug, "/" ) . "/", $slug ,$termlink, 1 ) |
|
| 1738 | + ); |
|
| 1739 | 1739 | |
| 1740 | - } |
|
| 1741 | - } |
|
| 1740 | + } |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | - } |
|
| 1743 | + } |
|
| 1744 | 1744 | |
| 1745 | - return $termlink; |
|
| 1745 | + return $termlink; |
|
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | 1748 | /** |
@@ -1768,14 +1768,14 @@ discard block |
||
| 1768 | 1768 | if (in_array($post_type, geodir_get_posttypes())) {
|
| 1769 | 1769 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
|
| 1770 | 1770 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
|
| 1771 | - $location_terms = array( |
|
| 1772 | - 'gd_country' => $post->country_slug, |
|
| 1773 | - 'gd_region' => $post->region_slug, |
|
| 1774 | - 'gd_city' => $post->city_slug |
|
| 1775 | - ); |
|
| 1776 | - } else {
|
|
| 1777 | - $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1778 | - } |
|
| 1771 | + $location_terms = array( |
|
| 1772 | + 'gd_country' => $post->country_slug, |
|
| 1773 | + 'gd_region' => $post->region_slug, |
|
| 1774 | + 'gd_city' => $post->city_slug |
|
| 1775 | + ); |
|
| 1776 | + } else {
|
|
| 1777 | + $location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1778 | + } |
|
| 1779 | 1779 | |
| 1780 | 1780 | $location_terms = geodir_remove_location_terms($location_terms); |
| 1781 | 1781 | |
@@ -1806,14 +1806,14 @@ discard block |
||
| 1806 | 1806 | */ |
| 1807 | 1807 | function get_post_type_singular_label($post_type, $echo = false) |
| 1808 | 1808 | {
|
| 1809 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1810 | - if (!is_object($obj_post_type)) {
|
|
| 1811 | - return; |
|
| 1812 | - } |
|
| 1813 | - if ($echo) |
|
| 1814 | - echo $obj_post_type->labels->singular_name; |
|
| 1815 | - else |
|
| 1816 | - return $obj_post_type->labels->singular_name; |
|
| 1809 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1810 | + if (!is_object($obj_post_type)) {
|
|
| 1811 | + return; |
|
| 1812 | + } |
|
| 1813 | + if ($echo) |
|
| 1814 | + echo $obj_post_type->labels->singular_name; |
|
| 1815 | + else |
|
| 1816 | + return $obj_post_type->labels->singular_name; |
|
| 1817 | 1817 | |
| 1818 | 1818 | } |
| 1819 | 1819 | |
@@ -1828,16 +1828,16 @@ discard block |
||
| 1828 | 1828 | */ |
| 1829 | 1829 | function get_post_type_plural_label($post_type, $echo = false) |
| 1830 | 1830 | {
|
| 1831 | - $all_postypes = geodir_get_posttypes(); |
|
| 1831 | + $all_postypes = geodir_get_posttypes(); |
|
| 1832 | 1832 | |
| 1833 | - if (!in_array($post_type, $all_postypes)) |
|
| 1834 | - return false; |
|
| 1833 | + if (!in_array($post_type, $all_postypes)) |
|
| 1834 | + return false; |
|
| 1835 | 1835 | |
| 1836 | - $obj_post_type = get_post_type_object($post_type); |
|
| 1837 | - if ($echo) |
|
| 1838 | - echo $obj_post_type->labels->name; |
|
| 1839 | - else |
|
| 1840 | - return $obj_post_type->labels->name; |
|
| 1836 | + $obj_post_type = get_post_type_object($post_type); |
|
| 1837 | + if ($echo) |
|
| 1838 | + echo $obj_post_type->labels->name; |
|
| 1839 | + else |
|
| 1840 | + return $obj_post_type->labels->name; |
|
| 1841 | 1841 | |
| 1842 | 1842 | } |
| 1843 | 1843 | |
@@ -1856,51 +1856,51 @@ discard block |
||
| 1856 | 1856 | */ |
| 1857 | 1857 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
| 1858 | 1858 | {
|
| 1859 | - global $wpdb; |
|
| 1860 | - |
|
| 1861 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1862 | - $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1863 | - |
|
| 1864 | - if (is_int($term)) {
|
|
| 1865 | - if (0 == $term) |
|
| 1866 | - return 0; |
|
| 1867 | - $where = 't.term_id = %d'; |
|
| 1868 | - if (!empty($taxonomy)) |
|
| 1869 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1870 | - else |
|
| 1871 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1872 | - } |
|
| 1859 | + global $wpdb; |
|
| 1860 | + |
|
| 1861 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
| 1862 | + $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
| 1863 | + |
|
| 1864 | + if (is_int($term)) {
|
|
| 1865 | + if (0 == $term) |
|
| 1866 | + return 0; |
|
| 1867 | + $where = 't.term_id = %d'; |
|
| 1868 | + if (!empty($taxonomy)) |
|
| 1869 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1870 | + else |
|
| 1871 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1872 | + } |
|
| 1873 | 1873 | |
| 1874 | - $term = trim(wp_unslash($term)); |
|
| 1874 | + $term = trim(wp_unslash($term)); |
|
| 1875 | 1875 | |
| 1876 | - if ('' === $slug = sanitize_title($term))
|
|
| 1877 | - return 0; |
|
| 1876 | + if ('' === $slug = sanitize_title($term))
|
|
| 1877 | + return 0; |
|
| 1878 | 1878 | |
| 1879 | - $where = 't.slug = %s'; |
|
| 1879 | + $where = 't.slug = %s'; |
|
| 1880 | 1880 | |
| 1881 | - $where_fields = array($slug); |
|
| 1882 | - if (!empty($taxonomy)) {
|
|
| 1883 | - $parent = (int)$parent; |
|
| 1884 | - if ($parent > 0) {
|
|
| 1885 | - $where_fields[] = $parent; |
|
| 1886 | - $else_where_fields[] = $parent; |
|
| 1887 | - $where .= ' AND tt.parent = %d'; |
|
| 1881 | + $where_fields = array($slug); |
|
| 1882 | + if (!empty($taxonomy)) {
|
|
| 1883 | + $parent = (int)$parent; |
|
| 1884 | + if ($parent > 0) {
|
|
| 1885 | + $where_fields[] = $parent; |
|
| 1886 | + $else_where_fields[] = $parent; |
|
| 1887 | + $where .= ' AND tt.parent = %d'; |
|
| 1888 | 1888 | |
| 1889 | - } |
|
| 1889 | + } |
|
| 1890 | 1890 | |
| 1891 | - $where_fields[] = $taxonomy; |
|
| 1891 | + $where_fields[] = $taxonomy; |
|
| 1892 | 1892 | |
| 1893 | 1893 | |
| 1894 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1895 | - return $result; |
|
| 1894 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
|
|
| 1895 | + return $result; |
|
| 1896 | 1896 | |
| 1897 | - return false; |
|
| 1898 | - } |
|
| 1897 | + return false; |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1901 | - return $result; |
|
| 1900 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1901 | + return $result; |
|
| 1902 | 1902 | |
| 1903 | - return false; |
|
| 1903 | + return false; |
|
| 1904 | 1904 | } |
| 1905 | 1905 | |
| 1906 | 1906 | /** |
@@ -1912,7 +1912,7 @@ discard block |
||
| 1912 | 1912 | function geodir_get_term_icon_rebuild() |
| 1913 | 1913 | {
|
| 1914 | 1914 | |
| 1915 | - update_option('gd_term_icons', '');
|
|
| 1915 | + update_option('gd_term_icons', '');
|
|
| 1916 | 1916 | |
| 1917 | 1917 | } |
| 1918 | 1918 | |
@@ -1930,60 +1930,60 @@ discard block |
||
| 1930 | 1930 | */ |
| 1931 | 1931 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
| 1932 | 1932 | {
|
| 1933 | - global $wpdb; |
|
| 1934 | - if (!$rebuild) {
|
|
| 1935 | - $terms_icons = get_option('gd_term_icons');
|
|
| 1936 | - } else {
|
|
| 1937 | - $terms_icons = ''; |
|
| 1938 | - } |
|
| 1939 | - |
|
| 1940 | - if (empty($terms_icons)) {
|
|
| 1941 | - $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 1942 | - $taxonomy = geodir_get_taxonomies(); |
|
| 1943 | - $post_types = geodir_get_posttypes(); |
|
| 1944 | - $tax_arr = array(); |
|
| 1945 | - foreach ($post_types as $post_type) {
|
|
| 1946 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
| 1947 | - } |
|
| 1948 | - $tax_c = implode(',', $tax_arr);
|
|
| 1949 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 1950 | - //$terms = get_terms( $taxonomy ); |
|
| 1951 | - |
|
| 1952 | - if($terms) {
|
|
| 1953 | - foreach ($terms as $term) {
|
|
| 1954 | - $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 1955 | - $a_terms[$post_type][] = $term; |
|
| 1933 | + global $wpdb; |
|
| 1934 | + if (!$rebuild) {
|
|
| 1935 | + $terms_icons = get_option('gd_term_icons');
|
|
| 1936 | + } else {
|
|
| 1937 | + $terms_icons = ''; |
|
| 1938 | + } |
|
| 1956 | 1939 | |
| 1957 | - } |
|
| 1958 | - } |
|
| 1940 | + if (empty($terms_icons)) {
|
|
| 1941 | + $default_icon_url = get_option('geodir_default_marker_icon');
|
|
| 1942 | + $taxonomy = geodir_get_taxonomies(); |
|
| 1943 | + $post_types = geodir_get_posttypes(); |
|
| 1944 | + $tax_arr = array(); |
|
| 1945 | + foreach ($post_types as $post_type) {
|
|
| 1946 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
| 1947 | + } |
|
| 1948 | + $tax_c = implode(',', $tax_arr);
|
|
| 1949 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
|
|
| 1950 | + //$terms = get_terms( $taxonomy ); |
|
| 1959 | 1951 | |
| 1960 | - if($a_terms) {
|
|
| 1961 | - foreach ($a_terms as $pt => $t2) {
|
|
| 1952 | + if($terms) {
|
|
| 1953 | + foreach ($terms as $term) {
|
|
| 1954 | + $post_type = str_replace("category", "", $term->taxonomy);
|
|
| 1955 | + $a_terms[$post_type][] = $term; |
|
| 1962 | 1956 | |
| 1963 | - foreach ($t2 as $term) {
|
|
| 1964 | - $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 1965 | - if ($term_icon) {
|
|
| 1966 | - $term_icon_url = $term_icon["src"]; |
|
| 1967 | - } else {
|
|
| 1968 | - $term_icon_url = $default_icon_url; |
|
| 1969 | - } |
|
| 1970 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
| 1971 | - } |
|
| 1972 | - } |
|
| 1973 | - } |
|
| 1957 | + } |
|
| 1958 | + } |
|
| 1974 | 1959 | |
| 1975 | - update_option('gd_term_icons', $terms_icons);
|
|
| 1976 | - } |
|
| 1960 | + if($a_terms) {
|
|
| 1961 | + foreach ($a_terms as $pt => $t2) {
|
|
| 1977 | 1962 | |
| 1978 | - if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 1979 | - return $terms_icons[$term_id]; |
|
| 1980 | - } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 1981 | - return get_option('geodir_default_marker_icon');
|
|
| 1982 | - } |
|
| 1963 | + foreach ($t2 as $term) {
|
|
| 1964 | + $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
| 1965 | + if ($term_icon) {
|
|
| 1966 | + $term_icon_url = $term_icon["src"]; |
|
| 1967 | + } else {
|
|
| 1968 | + $term_icon_url = $default_icon_url; |
|
| 1969 | + } |
|
| 1970 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
| 1971 | + } |
|
| 1972 | + } |
|
| 1973 | + } |
|
| 1974 | + |
|
| 1975 | + update_option('gd_term_icons', $terms_icons);
|
|
| 1976 | + } |
|
| 1983 | 1977 | |
| 1984 | - if (is_ssl()) {
|
|
| 1985 | - $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 1986 | - } |
|
| 1978 | + if ($term_id && isset($terms_icons[$term_id])) {
|
|
| 1979 | + return $terms_icons[$term_id]; |
|
| 1980 | + } elseif ($term_id && !isset($terms_icons[$term_id])) {
|
|
| 1981 | + return get_option('geodir_default_marker_icon');
|
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + if (is_ssl()) {
|
|
| 1985 | + $terms_icons = str_replace("http:","https:",$terms_icons );
|
|
| 1986 | + } |
|
| 1987 | 1987 | |
| 1988 | - return $terms_icons; |
|
| 1988 | + return $terms_icons; |
|
| 1989 | 1989 | } |
| 1990 | 1990 | \ No newline at end of file |