code cleanup
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
5 changed files
with
1 additions
and
304 deletions
| ... | @@ -32,9 +32,9 @@ if( function_exists('acf_add_options_page') ) { | ... | @@ -32,9 +32,9 @@ if( function_exists('acf_add_options_page') ) { |
| 32 | )); | 32 | )); |
| 33 | 33 | ||
| 34 | acf_register_block(array( | 34 | acf_register_block(array( |
| 35 | 'name' => 'call-out-block', | ||
| 36 | 'title' => __('Call Out Block'), | 35 | 'title' => __('Call Out Block'), |
| 37 | 'description' => __('A custom block for Call Out Block items.'), | 36 | 'description' => __('A custom block for Call Out Block items.'), |
| 37 | 'name' => 'call-out-block', | ||
| 38 | 'render_template' => 'blocks/call-out-block/call-out-block.php', | 38 | 'render_template' => 'blocks/call-out-block/call-out-block.php', |
| 39 | 'mode' => 'edit', | 39 | 'mode' => 'edit', |
| 40 | )); | 40 | )); | ... | ... |
| 1 | <?php | ||
| 2 | |||
| 3 | require_once( ABSPATH . 'wp-admin/admin.php' ); | ||
| 4 | |||
| 5 | //add_action('init','register_country_taxonomy'); | ||
| 6 | function register_country_taxonomy() { | ||
| 7 | error_log('dddd'); | ||
| 8 | $counties = array( | ||
| 9 | "Afghanistan", | ||
| 10 | "Albania", | ||
| 11 | "Algeria", | ||
| 12 | "Andorra", | ||
| 13 | "Angola", | ||
| 14 | "Antigua and Barbuda", | ||
| 15 | "Argentina", | ||
| 16 | "Armenia", | ||
| 17 | "Australia", | ||
| 18 | "Austria", | ||
| 19 | "Azerbaijan", | ||
| 20 | "Bahamas", | ||
| 21 | "Bahrain", | ||
| 22 | |||
| 23 | "Barbados", | ||
| 24 | "Belarus", | ||
| 25 | "Belgium", | ||
| 26 | "Belize", | ||
| 27 | "Benin", | ||
| 28 | "Bhutan", | ||
| 29 | "Bolivia", | ||
| 30 | "Bosnia and Herzegovina", | ||
| 31 | "Botswana", | ||
| 32 | "Brazil", | ||
| 33 | "Brunei", | ||
| 34 | "Bulgaria", | ||
| 35 | "Burkina Faso", | ||
| 36 | "Burundi", | ||
| 37 | "Cabo Verde", | ||
| 38 | "Cambodia", | ||
| 39 | |||
| 40 | "Canada", | ||
| 41 | "Central African Republic", | ||
| 42 | |||
| 43 | "Chile", | ||
| 44 | "China", | ||
| 45 | "Columbia", | ||
| 46 | "Comoros", | ||
| 47 | "Congo", | ||
| 48 | "Costa Rica", | ||
| 49 | "Croatia", | ||
| 50 | "Cuba", | ||
| 51 | "Cyprus", | ||
| 52 | "Czech Republic", | ||
| 53 | |||
| 54 | "Denmark", | ||
| 55 | "Djibouti", | ||
| 56 | "Dominica", | ||
| 57 | "Dominican Republic", | ||
| 58 | "East Timor", | ||
| 59 | "Ecuador", | ||
| 60 | |||
| 61 | "El Salvador", | ||
| 62 | "Equatorial Guinea", | ||
| 63 | "Eritrea", | ||
| 64 | "Estonia", | ||
| 65 | "Eswatini", | ||
| 66 | "Ethiopia", | ||
| 67 | "Fiji", | ||
| 68 | "Finland", | ||
| 69 | "France", | ||
| 70 | "Gabon", | ||
| 71 | "Gambia", | ||
| 72 | "Georgia", | ||
| 73 | "Germany", | ||
| 74 | "Ghana", | ||
| 75 | "Greece", | ||
| 76 | "Grenada", | ||
| 77 | "Guatemala", | ||
| 78 | "Guinea", | ||
| 79 | "Guinea", | ||
| 80 | "Guyana", | ||
| 81 | |||
| 82 | |||
| 83 | "Hungary", | ||
| 84 | "Iceland", | ||
| 85 | |||
| 86 | "Indonesia", | ||
| 87 | "Iran", | ||
| 88 | "Iraq", | ||
| 89 | "Ireland", | ||
| 90 | "Israel", | ||
| 91 | "Italy", | ||
| 92 | "Jamaica", | ||
| 93 | "Japan", | ||
| 94 | "Jordan", | ||
| 95 | "Kazakhstan", | ||
| 96 | "Kenya", | ||
| 97 | |||
| 98 | "North Korea", | ||
| 99 | "South Korea", | ||
| 100 | "Kuwait", | ||
| 101 | "Kyrgyzstan", | ||
| 102 | "Laos", | ||
| 103 | |||
| 104 | "Latvia", | ||
| 105 | "Lesotho", | ||
| 106 | "Libya", | ||
| 107 | "Liberia", | ||
| 108 | "Liechtenstein", | ||
| 109 | "Lithuania", | ||
| 110 | "Luxembourg", | ||
| 111 | "Madagascar", | ||
| 112 | "Malawi", | ||
| 113 | "Malaysia", | ||
| 114 | "Maldives", | ||
| 115 | "Mali", | ||
| 116 | "Malta", | ||
| 117 | "Marshall Islands", | ||
| 118 | "Mauritania", | ||
| 119 | "Mauritius", | ||
| 120 | "Mexico", | ||
| 121 | "Micronesia", | ||
| 122 | "Moldova", | ||
| 123 | "Monaco", | ||
| 124 | "Mongolia", | ||
| 125 | "Montenegro", | ||
| 126 | "Morocco", | ||
| 127 | "Mozambique", | ||
| 128 | "Myanmar", | ||
| 129 | "Namibia", | ||
| 130 | "Nauru", | ||
| 131 | "Nepal", | ||
| 132 | "Netherlands", | ||
| 133 | "New Zealand", | ||
| 134 | "Nicaragua", | ||
| 135 | "Nepal", | ||
| 136 | "Nigeria", | ||
| 137 | "North Macedonia", | ||
| 138 | "Norway", | ||
| 139 | "Oman", | ||
| 140 | |||
| 141 | "Palau", | ||
| 142 | "Panama", | ||
| 143 | "Papua New Guinea", | ||
| 144 | "Paraguay", | ||
| 145 | "Peru", | ||
| 146 | "Philippines", | ||
| 147 | "Poland", | ||
| 148 | "Portugal", | ||
| 149 | "Qatar", | ||
| 150 | "Romania", | ||
| 151 | "Russia", | ||
| 152 | "Rwanda", | ||
| 153 | "Saint Kitts and Nevis", | ||
| 154 | "Saint Lucia", | ||
| 155 | "Saint Vincent and the Grenadines", | ||
| 156 | "Samoa", | ||
| 157 | "San Marino", | ||
| 158 | "Sao Tome and Principe", | ||
| 159 | "Saudi Arabia", | ||
| 160 | "Senegal", | ||
| 161 | "Serbia", | ||
| 162 | "Seychelles", | ||
| 163 | "Sierra Leone", | ||
| 164 | "Singapore", | ||
| 165 | "Slovakia", | ||
| 166 | "Slovenia", | ||
| 167 | "Solomon Islands", | ||
| 168 | "Somalia", | ||
| 169 | "South Africa", | ||
| 170 | |||
| 171 | "Spain", | ||
| 172 | "Sri Lanka", | ||
| 173 | "Sudan", | ||
| 174 | "Suriname", | ||
| 175 | "Sweden", | ||
| 176 | "Switzerland", | ||
| 177 | "Syria", | ||
| 178 | "Taiwan", | ||
| 179 | "Tajikistan", | ||
| 180 | "Tanzania", | ||
| 181 | "Thailand", | ||
| 182 | "Togo", | ||
| 183 | "Tonga", | ||
| 184 | "Trinidad and Tobago", | ||
| 185 | "Tunisia", | ||
| 186 | "Turkey", | ||
| 187 | "Turkmenistan", | ||
| 188 | "Tuvalu", | ||
| 189 | "Uganda", | ||
| 190 | "Ukraine", | ||
| 191 | "United Arab Emirates", | ||
| 192 | "United Kingdom", | ||
| 193 | "United States", | ||
| 194 | "Uruguay", | ||
| 195 | "Uzbekistan", | ||
| 196 | "Vanuatu", | ||
| 197 | "Vatican City", | ||
| 198 | "Venezuela", | ||
| 199 | "Vietnam", | ||
| 200 | "Yemen", | ||
| 201 | "Zambia"); | ||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | foreach($counties as $country) { | ||
| 206 | |||
| 207 | register_taxonomy('country', 'attachment', array( | ||
| 208 | 'hierarchical' => true, | ||
| 209 | 'label' => $country, | ||
| 210 | 'query_var' => clean($country), | ||
| 211 | )); | ||
| 212 | |||
| 213 | |||
| 214 | register_taxonomy('country', 'documents', array( | ||
| 215 | 'hierarchical' => true, | ||
| 216 | 'label' => $country, | ||
| 217 | 'query_var' => clean($country), | ||
| 218 | )); | ||
| 219 | |||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 223 | function clean($string) { | ||
| 224 | $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. | ||
| 225 | |||
| 226 | return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. | ||
| 227 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -7,7 +7,6 @@ require_once 'shortcodes.php'; | ... | @@ -7,7 +7,6 @@ require_once 'shortcodes.php'; |
| 7 | require_once 'search-extras.php'; | 7 | require_once 'search-extras.php'; |
| 8 | require_once 'disable-comments.php'; | 8 | require_once 'disable-comments.php'; |
| 9 | require_once 'blocks.php'; | 9 | require_once 'blocks.php'; |
| 10 | require_once 'side-menu.php'; | ||
| 11 | require_once 'widgets-area.php'; | 10 | require_once 'widgets-area.php'; |
| 12 | require_once 'commands.php'; | 11 | require_once 'commands.php'; |
| 13 | require_once 'rest.php'; | 12 | require_once 'rest.php'; | ... | ... |
| ... | @@ -16,23 +16,6 @@ function wptp_add_tags_to_attachments() { | ... | @@ -16,23 +16,6 @@ function wptp_add_tags_to_attachments() { |
| 16 | add_action( 'init' , 'wptp_add_tags_to_attachments' ); | 16 | add_action( 'init' , 'wptp_add_tags_to_attachments' ); |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | function filter_query_args( $query_args, $sfid ) { | ||
| 20 | error_log(print_r($query_args,true)); | ||
| 21 | //$query_args['posts_per_page'] = -1; | ||
| 22 | //$query_args['orderby'] = 'relevance'; | ||
| 23 | //$query_args['order'] = 'ASC'; | ||
| 24 | |||
| 25 | return $query_args; | ||
| 26 | |||
| 27 | } | ||
| 28 | add_filter( 'sf_edit_query_args', 'filter_query_args', 99, 2 ); | ||
| 29 | |||
| 30 | function relevant_search_result( $q ) { | ||
| 31 | if ( is_search() && is_main_query() ) | ||
| 32 | $q->set( 'orderby', 'relevance'); | ||
| 33 | $q->set( 'order', 'ASC'); | ||
| 34 | } | ||
| 35 | //add_action( 'pre_get_posts', 'relevant_search_result' ); | ||
| 36 | 19 | ||
| 37 | add_action('init','set_exclude_from_search'); | 20 | add_action('init','set_exclude_from_search'); |
| 38 | function set_exclude_from_search() | 21 | function set_exclude_from_search() | ... | ... |
| 1 | <?php /** | ||
| 2 | * Use wp_list_pages() to display parent and all child pages of current page. | ||
| 3 | */ | ||
| 4 | function wpse_get_ancestor_tree() { | ||
| 5 | // Bail if this is not a page. | ||
| 6 | if ( ! is_page() ) { | ||
| 7 | return false; | ||
| 8 | } | ||
| 9 | |||
| 10 | // Get the current post. | ||
| 11 | $post = get_post(); | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Get array of post ancestor IDs. | ||
| 15 | * Note: The direct parent is returned as the first value in the array. | ||
| 16 | * The highest level ancestor is returned as the last value in the array. | ||
| 17 | * See https://codex.wordpress.org/Function_Reference/get_post_ancestors | ||
| 18 | */ | ||
| 19 | $ancestors = get_post_ancestors( $post->ID ); | ||
| 20 | |||
| 21 | // If there are ancestors, get the top level parent. | ||
| 22 | // Otherwise use the current post's ID. | ||
| 23 | $parent = ( ! empty( $ancestors ) ) ? array_pop( $ancestors ) : $post->ID; | ||
| 24 | |||
| 25 | // Get all pages that are a child of $parent. | ||
| 26 | $pages = get_pages( [ | ||
| 27 | 'child_of' => $parent, | ||
| 28 | ] ); | ||
| 29 | |||
| 30 | // Bail if there are no results. | ||
| 31 | if ( ! $pages ) { | ||
| 32 | return false; | ||
| 33 | } | ||
| 34 | |||
| 35 | // Store array of page IDs to include latere on. | ||
| 36 | $page_ids = array(); | ||
| 37 | foreach ( $pages as $page ) { | ||
| 38 | $page_ids[] = $page->ID; | ||
| 39 | } | ||
| 40 | |||
| 41 | // Add parent page to beginning of $page_ids array. | ||
| 42 | array_unshift( $page_ids, $parent ); | ||
| 43 | |||
| 44 | // Get the output and return results if they exist. | ||
| 45 | $output = wp_list_pages( [ | ||
| 46 | 'include' => $page_ids, | ||
| 47 | 'title_li' => false, | ||
| 48 | 'echo' => false, | ||
| 49 | ] ); | ||
| 50 | |||
| 51 | if ( ! $output ) { | ||
| 52 | return false; | ||
| 53 | } else { | ||
| 54 | return '<ul class="side-menu ancestor-tree">' . PHP_EOL . | ||
| 55 | $output . PHP_EOL . | ||
| 56 | '</ul>' . PHP_EOL; | ||
| 57 | } | ||
| 58 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment