Changeset 7505 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/gutenberg/functions.php
- Timestamp:
- 07/27/2018 02:23:28 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/gutenberg/functions.php
r7118 r7505 11 11 define( 'WPORGPATH', get_theme_file_path( '/inc/' ) ); 12 12 } 13 14 15 add_action( 'template_redirect', function() { 16 if ( ! is_page( 'test' ) ) { 17 return; 18 } 19 20 add_theme_support( 'align-wide' ); 21 show_admin_bar( true ); 22 23 add_action( 'wp_enqueue_scripts', function() { 24 wp_enqueue_script( 'postbox', admin_url( 'js/postbox.min.js' ),array( 'jquery-ui-sortable' ), false, 1 ); 25 wp_enqueue_style( 'dashicons' ); 26 wp_enqueue_style( 'common' ); 27 wp_enqueue_style( 'forms' ); 28 wp_enqueue_style( 'dashboard' ); 29 wp_enqueue_style( 'media' ); 30 wp_enqueue_style( 'admin-menu' ); 31 wp_enqueue_style( 'admin-bar' ); 32 wp_enqueue_style( 'nav-menus' ); 33 wp_enqueue_style( 'l10n' ); 34 wp_enqueue_style( 'buttons' ); 35 } ); 36 add_action( 'wp_enqueue_scripts', 'gutenberg_editor_scripts_and_styles' ); 37 38 if ( ! is_user_logged_in() ) { 39 add_filter( 'wp_insert_post_empty_content', '__return_true', PHP_INT_MAX -1, 2 ); 40 add_filter( 'pre_insert_term', function( $t ) {return ''; }); 41 } 42 43 44 // Disable use XML-RPC 45 add_filter( 'xmlrpc_enabled', '__return_false' ); 46 47 // Disable X-Pingback to header 48 function disable_x_pingback( $headers ) { 49 unset( $headers['X-Pingback'] ); 50 51 return $headers; 52 } 53 add_filter( 'wp_headers', 'disable_x_pingback' ); 54 55 /** 56 * Ajax handler for querying attachments. 57 * 58 * @since 3.5.0 59 */ 60 function frontenberg_wp_ajax_nopriv_query_attachments() { 61 $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 62 $keys = array( 63 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 64 'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum' 65 ); 66 foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { 67 if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { 68 $keys[] = $t->query_var; 69 } 70 } 71 72 $query = array_intersect_key( $query, array_flip( $keys ) ); 73 $query['post_type'] = 'attachment'; 74 if ( MEDIA_TRASH 75 && ! empty( $_REQUEST['query']['post_status'] ) 76 && 'trash' === $_REQUEST['query']['post_status'] ) { 77 $query['post_status'] = 'trash'; 78 } else { 79 $query['post_status'] = 'inherit'; 80 } 81 82 // Filter query clauses to include filenames. 83 if ( isset( $query['s'] ) ) { 84 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 85 } 86 87 /** 88 * Filters the arguments passed to WP_Query during an Ajax 89 * call for querying attachments. 90 * 91 * @since 3.7.0 92 * 93 * @see WP_Query::parse_query() 94 * 95 * @param array $query An array of query variables. 96 */ 97 $query = apply_filters( 'ajax_query_attachments_args', $query ); 98 $query = new WP_Query( $query ); 99 100 $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); 101 $posts = array_filter( $posts ); 102 103 wp_send_json_success( $posts ); 104 } 105 add_action( 'wp_ajax_nopriv_query-attachments', 'frontenberg_wp_ajax_nopriv_query_attachments' ); 106 }); 107 108 13 109 14 110 if ( ! function_exists( 'gutenbergtheme_setup' ) ) :
Note: See TracChangeset
for help on using the changeset viewer.