Changeset 2412316
- Timestamp:
- 11/04/2020 09:50:37 AM (5 years ago)
- Location:
- kodeks-dashboard/trunk
- Files:
-
- 3 edited
-
functions.php (modified) (14 diffs)
-
kodeks-dashboard.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kodeks-dashboard/trunk/functions.php
r2392216 r2412316 3 3 $inc_kodeks = get_template_directory() . '/inc/kodeks.php'; 4 4 if (!file_exists($inc_kodeks)) { 5 6 /* Enable / disable Dashboard */7 if (!isset($kodeks_options['setting_dashboard']) || $kodeks_options['setting_dashboard'] == 1) {8 // add new dashboard widgets9 function kodeks_add_dashboard_widgets() {10 wp_add_dashboard_widget( 'dashboard_welcome', 'Velkommen', 'kodeks_add_welcome_widget' );11 }12 13 add_action( 'wp_dashboard_setup', 'kodeks_add_dashboard_widgets' );14 15 function kodeks_add_welcome_widget(){ ?>5 6 /* Enable / disable Dashboard */ 7 if (!isset($kodeks_options['setting_dashboard']) || $kodeks_options['setting_dashboard'] == 1) { 8 // add new dashboard widgets 9 function kodeks_add_dashboard_widgets() { 10 wp_add_dashboard_widget( 'dashboard_welcome', 'Velkommen', 'kodeks_add_welcome_widget' ); 11 } 12 13 add_action( 'wp_dashboard_setup', 'kodeks_add_dashboard_widgets' ); 14 15 function kodeks_add_welcome_widget(){ ?> 16 16 <h1>Hei<?php $current_user = wp_get_current_user(); 17 if ($current_user->user_firstname != '') {18 echo ' ';19 echo $current_user->user_firstname; echo ','; } else {echo '!';}?></h1>17 if ($current_user->user_firstname != '') { 18 echo ' '; 19 echo $current_user->user_firstname; echo ','; } else {echo '!';}?></h1> 20 20 <p>Vi jobber kontinuerlig for at du skal kunne redigere dine nettsider så enkelt som mulig. Ved hjelp av Wordpress har dere total kontroll over alle deler av deres websider. Du kan selv oppdatere tekst, bilder og dokumenter på alle sider.</p> 21 21 <p>Har du spørsmål til løsningen eller ønsker oppdateringer på siden er du velkommen til å ta kontakt med oss.</p> … … 24 24 25 25 <?php 26 global $kodeks_options;27 if (!isset($kodeks_options['setting_news']) || $kodeks_options['setting_news'] == 1) {?>26 global $kodeks_options; 27 if (!isset($kodeks_options['setting_news']) || $kodeks_options['setting_news'] == 1) {?> 28 28 <hr/> 29 29 <h2>Nytt fra Kodeks</h2> 30 30 <?php // Get RSS Feed(s) 31 include_once( ABSPATH . WPINC . '/feed.php' );32 33 // Get a SimplePie feed object from the specified feed source.34 $rss = fetch_feed( 'https://kodeks.dev.kodeks.no/feed/' );35 36 $maxitems = 0;37 38 if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly39 40 // Figure out how many total items there are, but limit it to 5.41 $maxitems = $rss->get_item_quantity( 3 );42 43 // Build an array of all the items, starting with element 0 (first element).44 $rss_items = $rss->get_items( 0, $maxitems );45 46 endif;31 include_once( ABSPATH . WPINC . '/feed.php' ); 32 33 // Get a SimplePie feed object from the specified feed source. 34 $rss = fetch_feed( 'https://kodeks.dev.kodeks.no/feed/' ); 35 36 $maxitems = 0; 37 38 if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly 39 40 // Figure out how many total items there are, but limit it to 5. 41 $maxitems = $rss->get_item_quantity( 3 ); 42 43 // Build an array of all the items, starting with element 0 (first element). 44 $rss_items = $rss->get_items( 0, $maxitems ); 45 46 endif; 47 47 ?> 48 48 … … 62 62 </ul> 63 63 <?php 64 } 65 } 66 } 67 68 /* Enable / disable front page widgets */ 69 if (!isset($kodeks_options['setting_fp_widget_disable']) || $kodeks_options['setting_fp_widget_disable'] == 1) { 70 function kodeks_remove_dashboard_meta() { 71 remove_action('welcome_panel', 'wp_welcome_panel'); 72 remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); 73 remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); 74 remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); 75 remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' ); 76 remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); 77 remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); 78 remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); 79 remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); 80 remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');//since 3.8 81 remove_meta_box( 'jetpack_summary_widget', 'dashboard', 'normal' ); 82 remove_meta_box( 'tribe_dashboard_widget', 'dashboard', 'normal' ); 83 remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); 84 85 } 86 add_action( 'admin_init', 'kodeks_remove_dashboard_meta' ); 87 } 88 89 /* Enable / disable branding */ 90 if (!isset($kodeks_options['setting_branding']) || $kodeks_options['setting_branding'] == 1) { 91 /* Admin page style */ 92 function kodeks_admin_theme_style() { 93 wp_enqueue_style('my-admin-style', plugin_dir_url( __FILE__ ) . 'css/admin.css'); 94 } 95 add_action('admin_enqueue_scripts', 'kodeks_admin_theme_style'); 96 97 /* Edit footer-text */ 98 function wpse_edit_footer() { 99 add_filter( 'admin_footer_text', 'wpse_edit_text', 11 ); 100 } 101 102 function wpse_edit_text($content) { 103 return "WordPress levert av <a href='https://kodeks.no' target='_blank'>Kodeks AS</a>"; 104 } 105 add_action( 'admin_init', 'wpse_edit_footer' ); 106 107 /* Custom logo */ 108 function my_login_logo() { ?> 64 } 65 } 66 } 67 68 /* Enable / disable front page widgets */ 69 if (!isset($kodeks_options['setting_fp_widget_disable']) || $kodeks_options['setting_fp_widget_disable'] == 1) { 70 function kodeks_remove_dashboard_meta() { 71 remove_action('welcome_panel', 'wp_welcome_panel'); 72 remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); 73 remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); 74 remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); 75 remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' ); 76 remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); 77 remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); 78 remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); 79 remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); 80 remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');//since 3.8 81 remove_meta_box( 'jetpack_summary_widget', 'dashboard', 'normal' ); 82 remove_meta_box( 'tribe_dashboard_widget', 'dashboard', 'normal' ); 83 remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); 84 remove_meta_box( 'aaaa_webappick_latest_news_dashboard_widget', 'dashboard', 'side' ); 85 86 } 87 add_action( 'admin_init', 'kodeks_remove_dashboard_meta' ); 88 } 89 90 /* Enable / disable branding */ 91 if (!isset($kodeks_options['setting_branding']) || $kodeks_options['setting_branding'] == 1) { 92 /* Admin page style */ 93 function kodeks_admin_theme_style() { 94 wp_enqueue_style('my-admin-style', plugin_dir_url( __FILE__ ) . 'css/admin.css'); 95 } 96 add_action('admin_enqueue_scripts', 'kodeks_admin_theme_style'); 97 98 /* Edit footer-text */ 99 function wpse_edit_footer() { 100 add_filter( 'admin_footer_text', 'wpse_edit_text', 11 ); 101 } 102 103 function wpse_edit_text($content) { 104 return "WordPress levert av <a href='https://kodeks.no' target='_blank'>Kodeks AS</a>"; 105 } 106 add_action( 'admin_init', 'wpse_edit_footer' ); 107 108 /* Custom logo */ 109 function my_login_logo() { ?> 109 110 <style> 110 111 #login h1 a, .login h1 a { … … 121 122 </style> 122 123 <?php } 123 add_action( 'login_enqueue_scripts', 'my_login_logo' );124 125 // Endre link126 function my_login_logo_url() {127 return home_url();128 }129 add_filter( 'login_headerurl', 'my_login_logo_url' );130 131 function my_login_logo_url_title() {132 return 'Kodeks';133 }134 add_filter( 'login_headertext', 'my_login_logo_url_title' );135 136 // Legge til CSS137 function my_login_stylesheet() {138 wp_enqueue_style('custom-login', content_url() . '/plugins/kodeks-dashboard/css/admin.css');139 }140 add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );141 142 // Legge til hjelpetekst login page143 function smallenvelop_login_message( $message ) {144 if ( empty($message) ){145 return "<p class='kodeksInfo'><strong>Kodeks kundesenter: 21 00 01 01 — <a href='mailto:hjelp@kodeks.no'>hjelp@kodeks.no</a></strong></p>";146 } else {147 return $message;148 }149 }150 add_filter( 'login_message', 'smallenvelop_login_message' );151 }152 153 /* Enable / disable acl */154 if (!isset($kodeks_options['setting_acl']) || $kodeks_options['setting_acl'] == 1) {155 /*124 add_action( 'login_enqueue_scripts', 'my_login_logo' ); 125 126 // Endre link 127 function my_login_logo_url() { 128 return home_url(); 129 } 130 add_filter( 'login_headerurl', 'my_login_logo_url' ); 131 132 function my_login_logo_url_title() { 133 return 'Kodeks'; 134 } 135 add_filter( 'login_headertext', 'my_login_logo_url_title' ); 136 137 // Legge til CSS 138 function my_login_stylesheet() { 139 wp_enqueue_style('custom-login', content_url() . '/plugins/kodeks-dashboard/css/admin.css'); 140 } 141 add_action( 'login_enqueue_scripts', 'my_login_stylesheet' ); 142 143 // Legge til hjelpetekst login page 144 function smallenvelop_login_message( $message ) { 145 if ( empty($message) ){ 146 return "<p class='kodeksInfo'><strong>Kodeks kundesenter: 21 00 01 01 — <a href='mailto:hjelp@kodeks.no'>hjelp@kodeks.no</a></strong></p>"; 147 } else { 148 return $message; 149 } 150 } 151 add_filter( 'login_message', 'smallenvelop_login_message' ); 152 } 153 154 /* Enable / disable acl */ 155 if (!isset($kodeks_options['setting_acl']) || $kodeks_options['setting_acl'] == 1) { 156 /* 156 157 * Let Editors manage users, and run this only once. 157 158 */ 158 function isa_editor_manage_users() { 159 160 if ( get_option( 'isa_add_cap_editor_once' ) != 'done' ) { 161 162 // let editor manage users 163 164 $edit_editor = get_role('editor'); // Get the user role 165 $edit_editor->add_cap('edit_users'); 166 $edit_editor->add_cap('list_users'); 167 $edit_editor->add_cap('promote_users'); 168 $edit_editor->add_cap('create_users'); 169 $edit_editor->add_cap('add_users'); 170 $edit_editor->add_cap('delete_users'); 171 172 update_option( 'isa_add_cap_editor_once', 'done' ); 173 } 174 175 } 176 add_action( 'init', 'isa_editor_manage_users' ); 177 178 //prevent editor from deleting, editing, or creating an administrator 179 // only needed if the editor was given right to edit users 180 181 class ISA_User_Caps { 182 183 // Add our filters 184 function __construct() { 185 add_filter( 'editable_roles', array(&$this, 'editable_roles')); 186 add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4); 187 } 188 // Remove 'Administrator' from the list of roles if the current user is not an admin 189 function editable_roles( $roles ){ 190 if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){ 191 unset( $roles['administrator']); 192 } 193 return $roles; 194 } 195 // If someone is trying to edit or delete an 196 // admin and that user isn't an admin, don't allow it 197 function map_meta_cap( $caps, $cap, $user_id, $args ){ 198 switch( $cap ){ 199 case 'edit_user': 200 case 'remove_user': 201 case 'promote_user': 202 if( isset($args[0]) && $args[0] == $user_id ) 159 function isa_editor_manage_users() { 160 161 if ( get_option( 'isa_add_cap_editor_once' ) != 'done' ) { 162 163 // let editor manage users 164 165 $edit_editor = get_role('editor'); // Get the user role 166 $edit_editor->add_cap('edit_users'); 167 $edit_editor->add_cap('list_users'); 168 $edit_editor->add_cap('promote_users'); 169 $edit_editor->add_cap('create_users'); 170 $edit_editor->add_cap('add_users'); 171 $edit_editor->add_cap('delete_users'); 172 $edit_editor->remove_cap( 'unfiltered_html' ); 173 174 update_option( 'isa_add_cap_editor_once', 'done' ); 175 } 176 177 } 178 add_action( 'init', 'isa_editor_manage_users' ); 179 180 //prevent editor from deleting, editing, or creating an administrator 181 // only needed if the editor was given right to edit users 182 183 class ISA_User_Caps { 184 185 // Add our filters 186 function __construct() { 187 add_filter( 'editable_roles', array(&$this, 'editable_roles')); 188 add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4); 189 } 190 // Remove 'Administrator' from the list of roles if the current user is not an admin 191 function editable_roles( $roles ){ 192 if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){ 193 unset( $roles['administrator']); 194 } 195 return $roles; 196 } 197 // If someone is trying to edit or delete an 198 // admin and that user isn't an admin, don't allow it 199 function map_meta_cap( $caps, $cap, $user_id, $args ){ 200 switch( $cap ){ 201 case 'edit_user': 202 case 'remove_user': 203 case 'promote_user': 204 if( isset($args[0]) && $args[0] == $user_id ) 205 break; 206 elseif( !isset($args[0]) ) 207 $caps[] = 'do_not_allow'; 208 $other = new WP_User( absint($args[0]) ); 209 if( $other->has_cap( 'administrator' ) ){ 210 if(!current_user_can('administrator')){ 211 $caps[] = 'do_not_allow'; 212 } 213 } 203 214 break; 204 elseif( !isset($args[0]) ) 205 $caps[] = 'do_not_allow'; 206 $other = new WP_User( absint($args[0]) ); 207 if( $other->has_cap( 'administrator' ) ){ 208 if(!current_user_can('administrator')){ 209 $caps[] = 'do_not_allow'; 215 case 'delete_user': 216 case 'delete_users': 217 if( !isset($args[0]) ) 218 break; 219 $other = new WP_User( absint($args[0]) ); 220 if( $other->has_cap( 'administrator' ) ){ 221 if(!current_user_can('administrator')){ 222 $caps[] = 'do_not_allow'; 223 } 210 224 } 211 }212 break;213 case 'delete_user':214 case 'delete_users':215 if( !isset($args[0]) )216 225 break; 217 $other = new WP_User( absint($args[0]) ); 218 if( $other->has_cap( 'administrator' ) ){ 219 if(!current_user_can('administrator')){ 220 $caps[] = 'do_not_allow'; 221 } 222 } 223 break; 224 default: 225 break; 226 } 227 return $caps; 228 } 229 230 } 231 232 $isa_user_caps = new ISA_User_Caps(); 233 // Hide all administrators from user list. 234 add_action('pre_user_query','isa_pre_user_query'); 235 function isa_pre_user_query($user_search) { 236 237 $user = wp_get_current_user(); 238 239 if ( ! current_user_can( 'manage_options' ) ) { 240 241 global $wpdb; 242 243 $user_search->query_where = 244 str_replace('WHERE 1=1', 245 "WHERE 1=1 AND {$wpdb->users}.ID IN ( 226 default: 227 break; 228 } 229 return $caps; 230 } 231 232 } 233 234 $isa_user_caps = new ISA_User_Caps(); 235 // Hide all administrators from user list. 236 add_action('pre_user_query','isa_pre_user_query'); 237 function isa_pre_user_query($user_search) { 238 239 $user = wp_get_current_user(); 240 241 if ( ! current_user_can( 'manage_options' ) ) { 242 243 global $wpdb; 244 245 $user_search->query_where = 246 str_replace('WHERE 1=1', 247 "WHERE 1=1 AND {$wpdb->users}.ID IN ( 246 248 SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta 247 249 WHERE {$wpdb->usermeta}.meta_key = '{$wpdb->prefix}capabilities' 248 250 AND {$wpdb->usermeta}.meta_value NOT LIKE '%administrator%')", 249 $user_search->query_where250 );251 }252 }253 }254 255 /* Enable / disable emoji */256 if (!isset($kodeks_options['setting_emoji']) || $kodeks_options['setting_emoji'] == 1) {257 add_filter( 'emoji_svg_url', '__return_false' );258 add_action( 'init', 'disable_wp_emojicons' );259 260 function disable_wp_emojicons() {261 // all actions related to emojis262 remove_action( 'admin_print_styles', 'print_emoji_styles' );263 remove_action( 'wp_head', 'print_emoji_detection_script', 7 );264 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );265 remove_action( 'wp_print_styles', 'print_emoji_styles' );266 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );267 remove_filter( 'the_content_feed', 'wp_staticize_emoji' );268 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );269 // filter to remove TinyMCE emojis270 add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );271 }272 273 function disable_emojicons_tinymce( $plugins ) {274 if ( is_array( $plugins ) ) {275 return array_diff( $plugins, array( 'wpemoji' ) );276 } else {277 return array();278 }279 }280 }281 282 /* Enable / disable rest API */283 if (!isset($kodeks_options['setting_api']) || $kodeks_options['setting_api'] == 1) {284 285 remove_action ('wp_head', 'rsd_link');286 remove_action( 'wp_head', 'wlwmanifest_link');287 remove_action('template_redirect', 'rest_output_link_header', 11, 0);288 remove_action('wp_head', 'rest_output_link_wp_head', 10);289 290 // Sikkerhet - slå av xml-rpc291 // Disable use XML-RPC292 add_filter('xmlrpc_enabled', '__return_false');293 294 // Disable X-Pingback to header295 add_filter( 'wp_headers', 'disable_x_pingback' );296 function disable_x_pingback( $headers ) {297 unset( $headers['X-Pingback'] );298 return $headers;299 }300 301 // Turn off oEmbed auto discovery.302 add_filter( 'embed_oembed_discover', '__return_false' );303 304 // Don't filter oEmbed results.305 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );306 307 // Remove oEmbed discovery links.308 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );309 310 // Remove oEmbed-specific JavaScript from the front-end and back-end.311 remove_action( 'wp_head', 'wp_oembed_add_host_js' );312 313 /**251 $user_search->query_where 252 ); 253 } 254 } 255 } 256 257 /* Enable / disable emoji */ 258 if (!isset($kodeks_options['setting_emoji']) || $kodeks_options['setting_emoji'] == 1) { 259 add_filter( 'emoji_svg_url', '__return_false' ); 260 add_action( 'init', 'disable_wp_emojicons' ); 261 262 function disable_wp_emojicons() { 263 // all actions related to emojis 264 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 265 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 266 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 267 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 268 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 269 remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 270 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 271 // filter to remove TinyMCE emojis 272 add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' ); 273 } 274 275 function disable_emojicons_tinymce( $plugins ) { 276 if ( is_array( $plugins ) ) { 277 return array_diff( $plugins, array( 'wpemoji' ) ); 278 } else { 279 return array(); 280 } 281 } 282 } 283 284 /* Enable / disable rest API */ 285 if (!isset($kodeks_options['setting_api']) || $kodeks_options['setting_api'] == 1) { 286 287 remove_action ('wp_head', 'rsd_link'); 288 remove_action( 'wp_head', 'wlwmanifest_link'); 289 remove_action('template_redirect', 'rest_output_link_header', 11, 0); 290 remove_action('wp_head', 'rest_output_link_wp_head', 10); 291 292 // Sikkerhet - slå av xml-rpc 293 // Disable use XML-RPC 294 add_filter('xmlrpc_enabled', '__return_false'); 295 296 // Disable X-Pingback to header 297 add_filter( 'wp_headers', 'disable_x_pingback' ); 298 function disable_x_pingback( $headers ) { 299 unset( $headers['X-Pingback'] ); 300 return $headers; 301 } 302 303 // Turn off oEmbed auto discovery. 304 add_filter( 'embed_oembed_discover', '__return_false' ); 305 306 // Don't filter oEmbed results. 307 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); 308 309 // Remove oEmbed discovery links. 310 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 311 312 // Remove oEmbed-specific JavaScript from the front-end and back-end. 313 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 314 315 /** 314 316 * Disables WordPress Rest API for external requests 315 317 */ 316 // function restrict_rest_api_to_localhost() {317 // $whitelist = array('127.0.0.1', "::1");318 //319 // if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){320 // die('REST API is disabled.');321 // }322 // }323 // add_action( 'rest_api_init', 'restrict_rest_api_to_localhost', 1 );324 }325 326 /* Enable / disable admin-bar */327 if (!isset($kodeks_options['setting_adminbar']) || $kodeks_options['setting_adminbar'] == 1) {328 add_filter('show_admin_bar', 'remove_admin_bar');329 function remove_admin_bar() {330 return false;331 }332 }333 334 /* Enable / disable widgets */335 if (!isset($kodeks_options['setting_widget']) || $kodeks_options['setting_widget'] == 0) {336 /**318 // function restrict_rest_api_to_localhost() { 319 // $whitelist = array('127.0.0.1', "::1"); 320 // 321 // if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){ 322 // die('REST API is disabled.'); 323 // } 324 // } 325 // add_action( 'rest_api_init', 'restrict_rest_api_to_localhost', 1 ); 326 } 327 328 /* Enable / disable admin-bar */ 329 if (!isset($kodeks_options['setting_adminbar']) || $kodeks_options['setting_adminbar'] == 1) { 330 add_filter('show_admin_bar', 'remove_admin_bar'); 331 function remove_admin_bar() { 332 return false; 333 } 334 } 335 336 /* Enable / disable widgets */ 337 if (!isset($kodeks_options['setting_widget']) || $kodeks_options['setting_widget'] == 0) { 338 /** 337 339 * Register widget area. 338 340 * 339 341 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar 340 342 */ 341 function kodeks_widgets_init() {342 register_sidebar( array(343 'name' => esc_html__( 'Widgets', 'kodeks' ),344 'id' => 'widgets',345 'description' => esc_html__( 'Add widgets here.', 'kodeks' ),346 'before_widget' => '<section id="%1$s" class="widget %2$s">',347 'after_widget' => '</section>',348 'before_title' => '<h2 class="widget-title">',349 'after_title' => '</h2>',350 ) );351 }352 add_action( 'widgets_init', 'kodeks_widgets_init' );353 }354 355 /* Gutenberg */356 357 if (!isset($kodeks_options['setting_gutenberg']) || $kodeks_options['setting_gutenberg'] == 1) {358 add_action( 'enqueue_block_editor_assets', function() {359 // Main block styles.360 wp_enqueue_style( 'uuups-blocks', asset( 'styles/editor.css' ), null, null );361 362 // Overwrite Core block styles with empty styles.363 wp_deregister_style( 'wp-block-library' );364 wp_register_style( 'wp-block-library', '' );365 366 // Overwrite Core theme styles with empty styles.367 wp_deregister_style( 'wp-block-library-theme' );368 wp_register_style( 'wp-block-library-theme', '' );369 }, 10 );370 371 function custom_theme_assets() {372 wp_dequeue_style( 'wp-block-library' );373 }374 375 add_action( 'wp_enqueue_scripts', 'custom_theme_assets', 100 );376 }377 378 379 /* Enable / disable css */380 if (!isset($kodeks_options['setting_css']) || $kodeks_options['setting_css'] == 1) {381 382 /**343 function kodeks_widgets_init() { 344 register_sidebar( array( 345 'name' => esc_html__( 'Widgets', 'kodeks' ), 346 'id' => 'widgets', 347 'description' => esc_html__( 'Add widgets here.', 'kodeks' ), 348 'before_widget' => '<section id="%1$s" class="widget %2$s">', 349 'after_widget' => '</section>', 350 'before_title' => '<h2 class="widget-title">', 351 'after_title' => '</h2>', 352 ) ); 353 } 354 add_action( 'widgets_init', 'kodeks_widgets_init' ); 355 } 356 357 /* Gutenberg */ 358 359 if (!isset($kodeks_options['setting_gutenberg']) || $kodeks_options['setting_gutenberg'] == 1) { 360 add_action( 'enqueue_block_editor_assets', function() { 361 // Main block styles. 362 wp_enqueue_style( 'uuups-blocks', asset( 'styles/editor.css' ), null, null ); 363 364 // Overwrite Core block styles with empty styles. 365 wp_deregister_style( 'wp-block-library' ); 366 wp_register_style( 'wp-block-library', '' ); 367 368 // Overwrite Core theme styles with empty styles. 369 wp_deregister_style( 'wp-block-library-theme' ); 370 wp_register_style( 'wp-block-library-theme', '' ); 371 }, 10 ); 372 373 function custom_theme_assets() { 374 wp_dequeue_style( 'wp-block-library' ); 375 } 376 377 add_action( 'wp_enqueue_scripts', 'custom_theme_assets', 100 ); 378 } 379 380 381 /* Enable / disable css */ 382 if (!isset($kodeks_options['setting_css']) || $kodeks_options['setting_css'] == 1) { 383 384 /** 383 385 * Remove the additional CSS section, introduced in 4.7, from the Customizer. 384 386 * @param $wp_customize WP_Customize_Manager 385 387 */ 386 add_action( 'customize_register', 'prefix_remove_css_section', 15 ); 387 function prefix_remove_css_section( $wp_customize ) { 388 $wp_customize->remove_section( 'custom_css' ); 389 } 390 } 391 392 /* Default */ 393 394 // Fjerne static_front_page 395 396 add_action( 'customize_register', 'prefix_remove_front', 15 ); 397 function prefix_remove_front( $wp_customize ) { 398 $wp_customize->remove_section( 'static_front_page' ); 399 } 400 401 402 // Fjerne theme-picker 403 remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); 404 405 // Custom logo 406 add_theme_support('custom-logo'); 407 408 // Slå av editering via admin 409 define('DISALLOW_FILE_EDIT', true); 410 411 412 // remove version from head 413 remove_action('wp_head', 'wp_generator'); 414 415 // remove version from rss 416 add_filter('the_generator', '__return_empty_string'); 417 418 // remove version from scripts and styles 419 function shapeSpace_remove_version_scripts_styles($src) { 420 if (strpos($src, 'ver=')) { 421 $src = remove_query_arg('ver', $src); 422 } 423 return $src; 424 } 425 add_filter('style_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999); 426 add_filter('script_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999); 427 428 429 // Media uploader - enable SVG 430 function cc_mime_types($mimes) { 431 $mimes['svg'] = 'image/svg+xml'; 432 return $mimes; 433 } 434 add_filter('upload_mimes', 'cc_mime_types'); 435 436 // Move Yoast to bottom 437 function yoasttobottom() { 438 return 'low'; 439 } 440 add_filter( 'wpseo_metabox_prio', 'yoasttobottom'); 441 442 // Remove All Yoast HTML Comments 443 // https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 444 add_action('wp_head',function() { ob_start(function($o) { 445 return preg_replace('/^\n?<!--.*?[Y]oast.*?-->\n?$/mi','',$o); 446 }); },~PHP_INT_MAX); 447 448 449 // STOP TINYMCE CLASSES 450 add_filter('tiny_mce_before_init', 'customize_tinymce'); 451 452 function customize_tinymce($in) { 453 $in['paste_preprocess'] = "function(pl,o){ o.content = o.content.replace(/p class=\"p[0-9]+\"/g,'p'); o.content = o.content.replace(/span class=\"s[0-9]+\"/g,'span'); }"; 454 return $in; 455 } 456 457 /* Remove edit-button */ 458 add_filter( 'edit_post_link', '__return_false' ); 459 460 // block WP enum scans 461 // https://m0n.co/enum 462 if (!is_admin()) { 463 // default URL format 464 if (preg_match('/author=([0-9]*)/i', $_SERVER['QUERY_STRING'])) die(); 465 add_filter('redirect_canonical', 'shapeSpace_check_enum', 10, 2); 466 } 467 function shapeSpace_check_enum($redirect, $request) { 468 // permalink URL format 469 if (preg_match('/\?author=([0-9]*)(\/*)/i', $request)) die(); 470 else return $redirect; 471 } 472 473 add_action('init','do_stuff'); 474 function do_stuff(){ 475 $current_user = wp_get_current_user(); 476 // Disable W3TC footer comment for everyone but Admins (single site & network mode) 477 if ( !current_user_can( 'activate_plugins' ) ) { 478 add_filter( 'w3tc_can_print_comment', '__return_false', 10, 1 ); 479 } 480 481 } 482 483 // Remove type="javascript/css" 484 485 add_action( 'template_redirect', function(){ 486 ob_start( function( $buffer ){ 487 $buffer = str_replace( array( 'type="text/javascript"', "type='text/javascript'" ), '', $buffer ); 488 489 // Also works with other attributes... 490 $buffer = str_replace( array( 'type="text/css"', "type='text/css'" ), '', $buffer ); 491 $buffer = str_replace( array( 'frameborder="0"', "frameborder='0'" ), '', $buffer ); 492 $buffer = str_replace( array( 'scrolling="no"', "scrolling='no'" ), '', $buffer ); 493 494 return $buffer; 388 add_action( 'customize_register', 'prefix_remove_css_section', 15 ); 389 function prefix_remove_css_section( $wp_customize ) { 390 $wp_customize->remove_section( 'custom_css' ); 391 } 392 } 393 394 /* Default */ 395 396 // Fjerne static_front_page 397 398 add_action( 'customize_register', 'prefix_remove_front', 15 ); 399 function prefix_remove_front( $wp_customize ) { 400 $wp_customize->remove_section( 'static_front_page' ); 401 } 402 403 404 // Fjerne theme-picker 405 remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); 406 407 // Custom logo 408 add_theme_support('custom-logo'); 409 410 // Slå av editering via admin 411 define('DISALLOW_FILE_EDIT', true); 412 413 414 // remove version from head 415 remove_action('wp_head', 'wp_generator'); 416 417 // remove version from rss 418 add_filter('the_generator', '__return_empty_string'); 419 420 // remove version from scripts and styles 421 function shapeSpace_remove_version_scripts_styles($src) { 422 if (strpos($src, 'ver=')) { 423 $src = remove_query_arg('ver', $src); 424 } 425 return $src; 426 } 427 add_filter('style_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999); 428 add_filter('script_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999); 429 430 431 // Media uploader - enable SVG 432 function cc_mime_types($mimes) { 433 $mimes['svg'] = 'image/svg+xml'; 434 return $mimes; 435 } 436 add_filter('upload_mimes', 'cc_mime_types'); 437 438 // Move Yoast to bottom 439 function yoasttobottom() { 440 return 'low'; 441 } 442 add_filter( 'wpseo_metabox_prio', 'yoasttobottom'); 443 444 // Remove All Yoast HTML Comments 445 // https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 446 add_action('wp_head',function() { ob_start(function($o) { 447 return preg_replace('/^\n?<!--.*?[Y]oast.*?-->\n?$/mi','',$o); 448 }); },~PHP_INT_MAX); 449 450 451 // STOP TINYMCE CLASSES 452 add_filter('tiny_mce_before_init', 'customize_tinymce'); 453 454 function customize_tinymce($in) { 455 $in['paste_preprocess'] = "function(pl,o){ o.content = o.content.replace(/p class=\"p[0-9]+\"/g,'p'); o.content = o.content.replace(/span class=\"s[0-9]+\"/g,'span'); }"; 456 return $in; 457 } 458 459 /* Remove edit-button */ 460 add_filter( 'edit_post_link', '__return_false' ); 461 462 // block WP enum scans 463 // https://m0n.co/enum 464 if (!is_admin()) { 465 // default URL format 466 if (preg_match('/author=([0-9]*)/i', $_SERVER['QUERY_STRING'])) die(); 467 add_filter('redirect_canonical', 'shapeSpace_check_enum', 10, 2); 468 } 469 function shapeSpace_check_enum($redirect, $request) { 470 // permalink URL format 471 if (preg_match('/\?author=([0-9]*)(\/*)/i', $request)) die(); 472 else return $redirect; 473 } 474 475 add_action('init','do_stuff'); 476 function do_stuff(){ 477 $current_user = wp_get_current_user(); 478 // Disable W3TC footer comment for everyone but Admins (single site & network mode) 479 if ( !current_user_can( 'activate_plugins' ) ) { 480 add_filter( 'w3tc_can_print_comment', '__return_false', 10, 1 ); 481 } 482 483 } 484 485 // Remove type="javascript/css" 486 487 add_action( 'template_redirect', function(){ 488 ob_start( function( $buffer ){ 489 $buffer = str_replace( array( 'type="text/javascript"', "type='text/javascript'" ), '', $buffer ); 490 491 // Also works with other attributes... 492 $buffer = str_replace( array( 'type="text/css"', "type='text/css'" ), '', $buffer ); 493 $buffer = str_replace( array( 'frameborder="0"', "frameborder='0'" ), '', $buffer ); 494 $buffer = str_replace( array( 'scrolling="no"', "scrolling='no'" ), '', $buffer ); 495 496 return $buffer; 497 }); 495 498 }); 496 }); 497 498 // remove links/menus from the admin bar 499 function mytheme_admin_bar_render() { 500 global $wp_admin_bar; 501 $wp_admin_bar->remove_menu('comments'); 502 $wp_admin_bar->remove_menu('updates'); 503 } 504 add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' ); 505 506 507 function jp_wpseo_fat_slicer() { 508 509 // Only do this for users who don't have Editor capabilities 510 if ( ! current_user_can( 'edit_others_posts' ) ) { 511 add_action( 'add_meta_boxes', 'jp_remove_yoast_metabox', 99 ); 512 add_filter( 'manage_edit-post_columns', 'jp_remove_columns' ); 513 add_filter( 'manage_edit-page_columns', 'jp_remove_columns' ); 514 // add_filter( 'manage_edit-CPTNAME_columns', 'jp_remove_columns' ); // Replace CPTNAME with your custom post type name, for example "restaurants". 515 } 516 } 517 add_action( 'init', 'jp_wpseo_fat_slicer' ); 518 519 520 521 /** 499 500 // remove links/menus from the admin bar 501 function mytheme_admin_bar_render() { 502 global $wp_admin_bar; 503 $wp_admin_bar->remove_menu('comments'); 504 $wp_admin_bar->remove_menu('updates'); 505 } 506 add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' ); 507 508 509 function jp_wpseo_fat_slicer() { 510 511 // Only do this for users who don't have Editor capabilities 512 if ( ! current_user_can( 'edit_others_posts' ) ) { 513 add_action( 'add_meta_boxes', 'jp_remove_yoast_metabox', 99 ); 514 add_filter( 'manage_edit-post_columns', 'jp_remove_columns' ); 515 add_filter( 'manage_edit-page_columns', 'jp_remove_columns' ); 516 // add_filter( 'manage_edit-CPTNAME_columns', 'jp_remove_columns' ); // Replace CPTNAME with your custom post type name, for example "restaurants". 517 } 518 } 519 add_action( 'init', 'jp_wpseo_fat_slicer' ); 520 521 522 523 /** 522 524 * Removes the WordPress SEO meta box from posts and pages 523 525 * … … 525 527 * @uses remove_meta_box() 526 528 */ 527 function jp_remove_yoast_metabox() {528 529 $post_types = array( 'page', 'post' ); // add any custom post types here530 531 foreach( $post_types as $post_type ) {532 remove_meta_box( 'wpseo_meta', $post_type, 'normal' );533 }534 }535 536 537 538 /**529 function jp_remove_yoast_metabox() { 530 531 $post_types = array( 'page', 'post' ); // add any custom post types here 532 533 foreach( $post_types as $post_type ) { 534 remove_meta_box( 'wpseo_meta', $post_type, 'normal' ); 535 } 536 } 537 538 539 540 /** 539 541 * Removes the SEO item from the admin bar 540 542 * … … 542 544 * @uses remove_menu 543 545 */ 544 function jp_admin_bar_seo_cleanup() {545 546 global $wp_admin_bar;547 $wp_admin_bar->remove_menu( 'wpseo-menu' );548 }549 550 551 552 /**546 function jp_admin_bar_seo_cleanup() { 547 548 global $wp_admin_bar; 549 $wp_admin_bar->remove_menu( 'wpseo-menu' ); 550 } 551 552 553 554 /** 553 555 * Removes the extra columns on the post/page listing screens. 554 556 * 555 557 * @since 1.0.0 556 558 */ 557 function jp_remove_columns( $columns ) { 558 559 unset( $columns['wpseo-score'] ); 560 unset( $columns['wpseo-title'] ); 561 unset( $columns['wpseo-metadesc'] ); 562 unset( $columns['wpseo-focuskw'] ); 563 564 return $columns; 565 } 566 567 /** Hide update nag 568 */ 569 570 function hide_update_notice_to_all_but_admin_users() 571 { 572 if (!current_user_can('update_core')) { 573 remove_action( 'admin_notices', 'update_nag', 3 ); 574 remove_action( 'admin_notices', 'maintenance_nag', 10 ); 575 } 576 } 577 add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 ); 578 579 580 /* Show current teplate --- echo get_current_template( true ); */ 581 582 add_filter( 'template_include', 'var_template_include', 1000 ); 583 function var_template_include( $t ){ 584 $GLOBALS['current_theme_template'] = basename($t); 585 return $t; 586 } 587 588 function get_current_template( $echo = false ) { 589 if( !isset( $GLOBALS['current_theme_template'] ) ) 559 function jp_remove_columns( $columns ) { 560 561 unset( $columns['wpseo-score'] ); 562 unset( $columns['wpseo-title'] ); 563 unset( $columns['wpseo-metadesc'] ); 564 unset( $columns['wpseo-focuskw'] ); 565 566 return $columns; 567 } 568 569 /** Hide update nag 570 */ 571 572 function hide_update_notice_to_all_but_admin_users() 573 { 574 if (!current_user_can('update_core')) { 575 remove_action( 'admin_notices', 'update_nag', 3 ); 576 remove_action( 'admin_notices', 'maintenance_nag', 10 ); 577 } 578 } 579 add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 ); 580 581 582 /* Show current teplate --- echo get_current_template( true ); */ 583 584 add_filter( 'template_include', 'var_template_include', 1000 ); 585 function var_template_include( $t ){ 586 $GLOBALS['current_theme_template'] = basename($t); 587 return $t; 588 } 589 590 function get_current_template( $echo = false ) { 591 if( !isset( $GLOBALS['current_theme_template'] ) ) 592 return false; 593 if( $echo ) 594 echo $GLOBALS['current_theme_template']; 595 else 596 return $GLOBALS['current_theme_template']; 597 } 598 599 function is_post_type($type){ 600 global $wp_query; 601 if($type == get_post_type($wp_query->post->ID)) return true; 590 602 return false; 591 if( $echo ) 592 echo $GLOBALS['current_theme_template']; 593 else 594 return $GLOBALS['current_theme_template']; 595 } 596 597 function is_post_type($type){ 598 global $wp_query; 599 if($type == get_post_type($wp_query->post->ID)) return true; 600 return false; 601 } 602 603 // Add options page 604 605 if( function_exists('acf_add_options_page') ) { 606 607 acf_add_options_page(); 608 609 } 610 611 if ( ! function_exists( 'kodeks_setup' ) ) : 612 /** 603 } 604 605 // Add options page 606 607 if( function_exists('acf_add_options_page') ) { 608 609 acf_add_options_page(); 610 611 } 612 613 if ( ! function_exists( 'kodeks_setup' ) ) : 614 /** 613 615 * Sets up theme defaults and registers support for various WordPress features. 614 616 * … … 617 619 * as indicating support for post thumbnails. 618 620 */ 619 function kodeks_setup() {620 /*621 function kodeks_setup() { 622 /* 621 623 * Make theme available for translation. 622 624 * Translations can be filed in the /languages/ directory. … … 624 626 * to change 'kodeks' to the name of your theme in all the template files. 625 627 */ 626 load_theme_textdomain( 'kodeks', get_template_directory() . '/languages' );627 628 // Add default posts and comments RSS feed links to head.629 add_theme_support( 'automatic-feed-links' );630 631 /*628 load_theme_textdomain( 'kodeks', get_template_directory() . '/languages' ); 629 630 // Add default posts and comments RSS feed links to head. 631 add_theme_support( 'automatic-feed-links' ); 632 633 /* 632 634 * Let WordPress manage the document title. 633 635 * By adding theme support, we declare that this theme does not use a … … 635 637 * provide it for us. 636 638 */ 637 add_theme_support( 'title-tag' );638 /*639 add_theme_support( 'title-tag' ); 640 /* 639 641 * Enable support for Post Thumbnails on posts and pages. 640 642 * 641 643 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ 642 644 */ 643 add_theme_support( 'post-thumbnails' );644 645 /*645 add_theme_support( 'post-thumbnails' ); 646 647 /* 646 648 * Switch default core markup for search form, comment form, and comments 647 649 * to output valid HTML5. 648 650 */ 649 add_theme_support( 'html5', array(650 'search-form',651 'comment-form',652 'comment-list',653 'gallery',654 'caption',655 ) );656 }657 endif;658 add_action( 'after_setup_theme', 'kodeks_setup' );659 660 661 /**651 add_theme_support( 'html5', array( 652 'search-form', 653 'comment-form', 654 'comment-list', 655 'gallery', 656 'caption', 657 ) ); 658 } 659 endif; 660 add_action( 'after_setup_theme', 'kodeks_setup' ); 661 662 663 /** 662 664 * Set the content width in pixels, based on the theme's design and stylesheet. 663 665 * … … 666 668 * @global int $content_width 667 669 */ 668 function kodeks_content_width() {669 $GLOBALS['content_width'] = apply_filters( 'kodeks_content_width', 640 );670 }671 add_action( 'after_setup_theme', 'kodeks_content_width', 0 );672 673 /**670 function kodeks_content_width() { 671 $GLOBALS['content_width'] = apply_filters( 'kodeks_content_width', 640 ); 672 } 673 add_action( 'after_setup_theme', 'kodeks_content_width', 0 ); 674 675 /** 674 676 * Enqueue scripts and styles. 675 677 */ 676 function kodeks_scripts() { 677 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 678 wp_enqueue_script( 'comment-reply' ); 679 } 680 } 681 add_action( 'wp_enqueue_scripts', 'kodeks_scripts' ); 682 683 // post thumbnails support 684 add_theme_support( 'post-thumbnails' ); 685 686 // Make editors able to edit privacy page 687 688 add_action('map_meta_cap', 'custom_manage_privacy_options', 1, 4); 689 function custom_manage_privacy_options($caps, $cap, $user_id, $args) 690 { 691 if ('manage_privacy_options' === $cap) { 692 $manage_name = is_multisite() ? 'manage_network' : 'manage_options'; 693 $caps = array_diff($caps, [ $manage_name ]); 694 } 695 return $caps; 696 } 697 698 add_filter( 'Yoast\WP\ACF\refresh_rate', function () { 699 // Refresh rates in milliseconds 700 return 20000; 701 }); 702 703 704 /** 678 function kodeks_scripts() { 679 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 680 wp_enqueue_script( 'comment-reply' ); 681 } 682 } 683 add_action( 'wp_enqueue_scripts', 'kodeks_scripts' ); 684 685 // post thumbnails support 686 add_theme_support( 'post-thumbnails' ); 687 688 // Make editors able to edit privacy page 689 690 add_action('map_meta_cap', 'custom_manage_privacy_options', 1, 4); 691 function custom_manage_privacy_options($caps, $cap, $user_id, $args) 692 { 693 if ('manage_privacy_options' === $cap) { 694 $manage_name = is_multisite() ? 'manage_network' : 'manage_options'; 695 $caps = array_diff($caps, [ $manage_name ]); 696 } 697 return $caps; 698 } 699 700 add_filter( 'Yoast\WP\ACF\refresh_rate', function () { 701 // Refresh rates in milliseconds 702 return 20000; 703 }); 704 705 706 707 // Fix ACF Preview 708 709 if ( !function_exists( 'kodeks_fix_post_id_on_preview' ) ){ 710 function kodeks_fix_post_id_on_preview($null, $post_id) { 711 if (is_preview()) { 712 return get_the_ID(); 713 } 714 else { 715 $acf_post_id = isset($post_id->ID) ? $post_id->ID : $post_id; 716 717 if (!empty($acf_post_id)) { 718 return $acf_post_id; 719 } 720 else { 721 return $null; 722 } 723 } 724 } 725 add_filter( 'acf/pre_load_post_id', 'fix_post_id_on_preview', 10, 2 ); 726 } 727 728 729 /** 705 730 * Extend WordPress search to include custom fields 706 731 * … … 708 733 */ 709 734 710 /**735 /** 711 736 * Join posts and postmeta tables 712 737 * … … 714 739 */ 715 740 716 $search_plugin = false;717 if(in_array('acf-better-search/acf-better-search.php', apply_filters('active_plugins', get_option('active_plugins')))){718 $search_plugin = true;719 };720 721 if ( ! function_exists( 'kodeks_search_join' ) && $search_plugin == false ) {722 723 function kodeks_search_join( $join ) {724 global $wpdb;725 726 if ( is_search() ) {727 $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';728 }729 730 return $join;731 }732 add_filter('posts_join', 'kodeks_search_join' );733 734 }735 736 /**741 $search_plugin = false; 742 if(in_array('acf-better-search/acf-better-search.php', apply_filters('active_plugins', get_option('active_plugins')))){ 743 $search_plugin = true; 744 }; 745 746 if ( ! function_exists( 'kodeks_search_join' ) && $search_plugin == false ) { 747 748 function kodeks_search_join( $join ) { 749 global $wpdb; 750 751 if ( is_search() || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], 'xmlhttprequest') == 0)) { 752 $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id '; 753 } 754 755 return $join; 756 } 757 add_filter('posts_join', 'kodeks_search_join' ); 758 759 } 760 761 /** 737 762 * Modify the search query with posts_where 738 763 * … … 740 765 */ 741 766 742 if ( ! function_exists( 'kodeks_search_where' ) && $search_plugin == false ) {743 function kodeks_search_where( $where ) {744 global $pagenow, $wpdb;745 746 if ( is_search()) {747 $where = preg_replace(748 "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",749 "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );750 }751 752 return $where;753 }754 add_filter( 'posts_where', 'kodeks_search_where' );755 }767 if ( ! function_exists( 'kodeks_search_where' ) && $search_plugin == false ) { 768 function kodeks_search_where( $where ) { 769 global $pagenow, $wpdb; 770 771 if ( is_search() || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], 'xmlhttprequest') == 0)) { 772 $where = preg_replace( 773 "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", 774 "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where ); 775 } 776 777 return $where; 778 } 779 add_filter( 'posts_where', 'kodeks_search_where' ); 780 } 756 781 757 782 /** … … 764 789 global $wpdb; 765 790 766 if ( is_search() ) {791 if ( is_search() || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], 'xmlhttprequest') == 0)) { 767 792 return "DISTINCT"; 768 793 } -
kodeks-dashboard/trunk/kodeks-dashboard.php
r2392216 r2412316 3 3 Plugin Name: Kodeks Dashboard 4 4 Description: This plugin customizes WordPress for Kodeks customers. 5 Version: 3.0. 65 Version: 3.0.7 6 6 Author: Thomas Johannessen & Marius Kaase 7 7 Author URI: http://kodeks.no … … 277 277 // add top level menu page 278 278 add_options_page( 279 'Kodeks Dashboard 2.0',279 'Kodeks Dashboard', 280 280 'Kodeks Dashboard', 281 281 'manage_options', -
kodeks-dashboard/trunk/readme.txt
r2392216 r2412316 1 1 === Kodeks Dashboard === 2 Version: 3.0. 62 Version: 3.0.7 3 3 Contributors: Kodeks AS 4 Tested up to: 5.5. 14 Tested up to: 5.5.3 5 5 License: GPLv2 or later 6 6 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.