cap->edit_terms ) ) { wp_die( -1 ); } $new_names = explode( ',', $_POST[ 'new' . $key ] ); $new_terms_markup = ''; foreach( $new_names as $name ) { if ( '' === sanitize_title( $name ) ) { continue; } if ( ! $id = term_exists( $name, $key ) ) { $id = wp_insert_term( $name, $key ); } if ( is_wp_error( $id ) ) { continue; } if ( is_array( $id ) ) { $id = absint( $id['term_id'] ); } else { continue; } $term = get_term( $id, $key ); $name = $term->name; $new_terms_markup .= "
\n"; } // foreach new_name $input_new_parent_name = "new{$key}_parent"; $supplemental = ""; $add = array( 'what' => $key, 'id' => $id, 'data' => $new_terms_markup, 'position' => -1, 'supplemental' => array( 'newcat_parent' => $supplemental ) ); $x = new WP_Ajax_Response( $add ); $x->send(); } // _mla_ajax_add_flat_term /** * Ajax handler to stream/view or download a Media Library item * * @since 2.63 * * @return void echo HTML for file streaming or download, then exit() */ public static function mla_named_transfer_ajax_action() { if ( !class_exists( 'MLAFileDownloader' ) ) { require_once( pathinfo( __FILE__, PATHINFO_DIRNAME ) . '/class-mla-file-downloader.php' ); } $download_args = array(); if ( empty( $_REQUEST['mla_item'] ) ) { $download_args['error'] = 'ERROR: mla_item argument not set.'; } else { $item_name = $_REQUEST['mla_item']; $args = array( 'name' => $item_name, 'post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => 1 ); $items = get_posts( $args ); if( $items ) { $file = get_attached_file( $items[0]->ID ); if ( !empty( $file ) ) { $download_args['mla_download_file'] = $file; $download_args['mla_download_type'] = $items[0]->post_mime_type; if ( !empty( $_REQUEST['mla_disposition'] ) ) { $download_args['mla_disposition'] = $_REQUEST['mla_disposition']; } } else { $download_args['error'] = 'ERROR: mla_item no attached file.'; } } else { $download_args['error'] = 'ERROR: mla_item not found.'; } } MLAFileDownloader::$mla_debug = isset( $_REQUEST['mla_debug'] ) && 'log' == $_REQUEST['mla_debug']; MLAFileDownloader::mla_process_download_file( $download_args ); MLACore::mla_debug_add( __LINE__ . " MLA_Ajax::mla_named_transfer_ajax_action failed. \$_REQUEST = " . var_export( $_REQUEST, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); echo "MLA_Ajax::mla_named_transfer_ajax_action failed."; die(); } // mla_named_transfer_ajax_action /** * Ajax handler to fetch candidates for the "Set Parent" popup window * * Adapted from wp_ajax_find_posts in /wp-admin/includes/ajax-actions.php. * Adds filters for post type and pagination. * * @since 1.90 * * @return void passes results to wp_send_json_success() for JSON encoding and transmission */ public static function mla_find_posts_ajax_action() { global $wpdb; check_ajax_referer( 'mla_find_posts', MLACore::MLA_ADMIN_NONCE_NAME ); $post_types = get_post_types( array( 'public' => true ), 'objects' ); unset( $post_types['attachment'] ); $s = stripslashes( $_REQUEST['mla_set_parent_search_text'] ); $count = isset( $_REQUEST['mla_set_parent_count'] ) ? $_REQUEST['mla_set_parent_count'] : 50; $paged = isset( $_REQUEST['mla_set_parent_paged'] ) ? $_REQUEST['mla_set_parent_paged'] : 1; $args = array( 'post_type' => ( 'all' == $_REQUEST['mla_set_parent_post_type'] ) ? array_keys( $post_types ) : $_REQUEST['mla_set_parent_post_type'], 'post_status' => 'any', 'posts_per_page' => $count, 'paged' => $paged, ); if ( '' !== $s ) $args['s'] = $s; $posts = get_posts( $args ); if ( ( ! $posts ) && $paged > 1 ) { $args['paged'] = $paged = 1; $posts = get_posts( $args ); } $found = count( $posts ); $html = '\n"; $html .= '\n"; $html .= '\n"; $html .= '| '.__('Title').' | '.__('Type').' | '.__('Date').' | '.__('Status').' | |
|---|---|---|---|---|
| '; $html .= ' | ' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . ' | '.esc_html( $time ) . ' | ' . esc_html( $stat ). ' | |
| '; $html .= ' | No results found. | |||