' . esc_html__( 'Posts', 'mainwp' ) . '', 'read', 'PostBulkManage', array( static::get_class_name(), 'render' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_page' ) ); add_filter( 'manage_' . $_page . '_columns', array( static::get_class_name(), 'get_manage_columns' ) ); if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PostBulkAdd' ) ) { $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Posts', 'mainwp' ), '
' . esc_html__( 'Add New', 'mainwp' ) . '
', 'read', 'PostBulkAdd', array( static::get_class_name(), 'render_bulk_add' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PostBulkEdit' ) ) { $_page = add_submenu_page( 'mainwp_tab', esc_html__( 'Posts', 'mainwp' ), '
' . esc_html__( 'Edit Post', 'mainwp' ) . '
', 'read', 'PostBulkEdit', array( static::get_class_name(), 'render_bulk_edit' ) ); add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_add_edit' ) ); } add_submenu_page( 'mainwp_tab', 'Posting new bulkpost', '
' . esc_html__( 'Posts', 'mainwp' ) . '
', 'read', 'PostingBulkPost', array( MainWP_Post_Page_Handler::get_class_name(), 'posting_bulk', ) ); /** * Posts Subpages * * Filters subpages for the Posts page. * * @since Unknown */ $sub_pages = array(); $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-post', array( $sub_pages ), '4.0.7.2', 'mainwp_getsubpages_post' ); // @deprecated Use 'mainwp_getsubpages_post' instead. NOSONAR - not IP. static::$subPages = apply_filters( 'mainwp_getsubpages_post', $sub_pages ); if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( MainWP_Menu::is_disable_menu_item( 3, 'Post' . $subPage['slug'] ) ) { continue; } add_submenu_page( 'mainwp_tab', $subPage['title'], '
' . $subPage['title'] . '
', 'read', 'Post' . $subPage['slug'], $subPage['callback'] ); } } static::init_left_menu( static::$subPages ); } /** * Method on_load_page() * * Used during init_menu() to get the class names of, * admin_head and get_hidden_columns. * * @return void */ public static function on_load_page() { add_action( 'admin_head', array( static::get_class_name(), 'admin_head' ) ); add_filter( 'hidden_columns', array( static::get_class_name(), 'get_hidden_columns' ), 10, 3 ); add_action( 'mainwp_screen_options_modal_bottom', array( static::get_class_name(), 'hook_screen_options_modal_bottom' ), 10, 2 ); } /** * Init custom bulkpost metaboxes. * * @return void */ public static function init_custom_metaboxes() { $metaboxes = apply_filters( 'mainwp_edit_bulkpost_getmetaboxes', array() ); // hooks load widgets for individual overview page and for manage sites's subpage. foreach ( $metaboxes as $idx => $metaBox ) { MainWP_UI::add_bulkpost_widget_box( $idx, $metaBox ); } } /** * Method get_fix_metabox_page(). * * @param string $page page. * * @return string */ public static function get_fix_metabox_page( $page ) { if ( 'mainwp_page_PostBulkAdd' === $page || 'mainwp_page_PostBulkEdit' === $page ) { $page = 'bulkpost'; } elseif ( 'mainwp_page_PageBulkAdd' === $page || 'mainwp_page_PageBulkEdit' === $page ) { $page = 'bulkpage'; } return $page; } /** * Method on_load_add_edit() * * Get the post ID, * pass it to method on_load_bulkpost(). * * @return void static::on_load_bulkpost( $post_id ). */ public static function on_load_add_edit() { global $_mainwp_menu_active_slugs; if ( isset( $_GET['page'] ) && 'PostBulkAdd' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized /** * MainWP default post to edit. * * @global string */ global $_mainwp_default_post_to_edit; $post_type = 'bulkpost'; $_mainwp_default_post_to_edit = get_default_post_to_edit( $post_type, true ); $post_id = $_mainwp_default_post_to_edit ? $_mainwp_default_post_to_edit->ID : 0; } else { $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $_mainwp_menu_active_slugs['PostBulkEdit'] = 'PostBulkManage'; // to fix hidden second menu level. } if ( ! $post_id ) { wp_die( esc_html__( 'Invalid post.', 'mainwp' ) ); } static::on_load_bulkpost( $post_id ); static::init_custom_metaboxes(); } /** * Method on_load_bulkpost() * * For the given post ID, this method Enqueues all scripts, styles, settings, * and templates necessary to use all media JS APIs, then retrieves post data. * * @param mixed $post_id Given post ID. * * @return void (WP_Post|array|null) Sets the Global variable $GLOBALS['post'], * Type corresponding to $output on success or null on failure. When $output is OBJECT, a WP_Post instance is returned. */ public static function on_load_bulkpost( $post_id ) { wp_enqueue_media( array( 'post' => $post_id ) ); wp_enqueue_script( 'mainwp-post', MAINWP_PLUGIN_URL . 'assets/js/mainwp-post-edit.js', array( 'jquery', 'postbox', 'word-count', 'media-views', 'mainwp', ), MAINWP_VERSION, true ); $_post = get_post( $post_id ); // phpcs:ignore -- required for custom bulk posts/pages and support hooks. $GLOBALS['post'] = $_post; } /** * Method get_manage_columns() * * Get columns to display. * * @return array $colums Array of columns to display on the page. * * @uses \MainWP\Dashboard\MainWP_Utility::enabled_wp_seo() */ public static function get_manage_columns() { $colums = array( 'title' => esc_html__( 'Title', 'mainwp' ), 'author' => esc_html__( 'Author', 'mainwp' ), 'date' => esc_html__( 'Last Modified', 'mainwp' ), 'categories' => esc_html__( 'Categories', 'mainwp' ), 'tags' => esc_html__( 'Tags', 'mainwp' ), 'post-type' => esc_html__( 'Post type', 'mainwp' ), 'comments' => esc_html__( 'Comments', 'mainwp' ), 'status' => esc_html__( 'Status', 'mainwp' ), 'seo-links' => esc_html__( 'Links', 'mainwp' ), 'seo-linked' => esc_html__( 'Linked', 'mainwp' ), 'seo-score' => esc_html__( 'SEO Score', 'mainwp' ), 'seo-readability' => esc_html__( 'Readability score', 'mainwp' ), 'website' => esc_html__( 'Website', 'mainwp' ), ); if ( ! MainWP_Utility::enabled_wp_seo() ) { unset( $colums['seo-links'] ); unset( $colums['seo-linked'] ); unset( $colums['seo-score'] ); unset( $colums['seo-readability'] ); } return $colums; } /** * Method admin_head() * * Grab the current_screen ID, set the pagenow JS variable, * and render the JS HTML Meta tag. * * @return void Render the Post pagenow header tag. */ public static function admin_head() { /** * Current screen. * * @global string */ global $current_screen; ?> id ) { $hidden = get_user_option( 'manage' . strtolower( $screen->id ) . 'columnshidden' ); } if ( ! is_array( $hidden ) ) { $hidden = array(); } return $hidden; } /** * Method hook_screen_options_modal_bottom() * * Render screen options modal bottom. */ public static function hook_screen_options_modal_bottom() { $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( 'PostBulkManage' === $page ) { $show_columns = get_user_option( 'mainwp_manageposts_show_columns' ); if ( ! is_array( $show_columns ) ) { $show_columns = array(); } $cols = static::get_manage_columns(); MainWP_UI::render_showhide_columns_settings( $cols, $show_columns, 'post' ); } } /** * Method init_subpages_menu() * * Initiate subpages menu. * * @return void Render subpages menu. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() */ public static function init_subpages_menu() { // phpcs:ignore -- NOSONAR - complex. ?> esc_html__( 'Posts', 'mainwp' ), 'parent_key' => 'managesites', 'slug' => 'PostBulkManage', 'href' => 'admin.php?page=PostBulkManage', 'icon' => '', 'leftsub_order' => 8, ), 1 ); $init_sub_subleftmenu = array( array( 'title' => esc_html__( 'Manage Posts', 'mainwp' ), 'parent_key' => 'PostBulkManage', 'href' => 'admin.php?page=PostBulkManage', 'slug' => 'PostBulkManage', 'right' => 'manage_posts', 'leftsub_order_level2' => 1, ), array( 'title' => esc_html__( 'Add New', 'mainwp' ), 'parent_key' => 'PostBulkManage', 'href' => 'admin.php?page=PostBulkAdd', 'slug' => 'PostBulkAdd', 'right' => 'manage_posts', 'leftsub_order_level2' => 2, ), ); MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'PostBulkManage', 'Post' ); foreach ( $init_sub_subleftmenu as $item ) { if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { continue; } MainWP_Menu::add_left_menu( $item, 2 ); } } /** * Method admin_post_thumbnail_html() * * Grab the post thumbnail html. * * @param mixed $content Admin post thumbnail HTML markup. * @param mixed $post_id Post ID. * @param mixed $thumbnail_id Thumbnail ID. * * @return string html */ public static function admin_post_thumbnail_html( $content, $post_id, $thumbnail_id ) { $_post = get_post( $post_id ); if ( empty( $_post ) ) { return $content; } if ( 'bulkpost' !== $_post->post_type && 'bulkpage' !== $_post->post_type ) { return $content; } return static::wp_post_thumbnail_html( $thumbnail_id, $post_id ); } /** * Method render_header() * * @param string $shownPage Current page slug. * @param null $post_id BulkEdit Post ID. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() */ public static function render_header( $shownPage = '', $post_id = null ) { // phpcs:ignore -- NOSONAR - complex. $params = array( 'title' => esc_html__( 'Posts', 'mainwp' ), ); MainWP_UI::render_top_header( $params ); $renderItems = array(); if ( \mainwp_current_user_can( 'dashboard', 'manage_posts' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Manage Posts', 'mainwp' ), 'href' => 'admin.php?page=PostBulkManage', 'active' => ( 'BulkManage' === $shownPage ) ? true : false, ); if ( 'BulkEdit' === $shownPage ) { $renderItems[] = array( 'title' => esc_html__( 'Edit Post', 'mainwp' ), 'href' => 'admin.php?page=PostBulkEdit&post_id=' . esc_attr( $post_id ), 'active' => true, ); } if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PostBulkAdd' ) ) { $renderItems[] = array( 'title' => esc_html__( 'Add New', 'mainwp' ), 'href' => 'admin.php?page=PostBulkAdd', 'active' => ( 'BulkAdd' === $shownPage ) ? true : false, ); } } if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { foreach ( static::$subPages as $subPage ) { if ( MainWP_Menu::is_disable_menu_item( 3, 'Post' . $subPage['slug'] ) ) { continue; } if ( isset( $subPage['tab_link_hidden'] ) && true === $subPage['tab_link_hidden'] ) { $tab_link = '#'; } else { $tab_link = 'admin.php?page=Post' . $subPage['slug']; } $item = array(); $item['title'] = $subPage['title']; $item['href'] = $tab_link; $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false; $renderItems[] = $item; } } MainWP_UI::render_page_navigation( $renderItems, __CLASS__ ); } /** * Method render_footer() * * Render page footer. */ public static function render_footer() { echo ''; } /** * Method render() * * Render the page content. * * @return string Post page html content. * * @uses \MainWP\Dashboard\MainWP_Cache::get_cached_context() */ public static function render() { // phpcs:ignore -- NOSONAR - complex. if ( ! \mainwp_current_user_can( 'dashboard', 'manage_posts' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage posts', 'mainwp' ) ); return; } $cachedSearch = MainWP_Cache::get_cached_context( 'Post' ); $selected_sites = array(); $selected_groups = array(); $selected_clients = array(); if ( null !== $cachedSearch ) { if ( is_array( $cachedSearch['sites'] ) ) { $selected_sites = $cachedSearch['sites']; } elseif ( is_array( $cachedSearch['groups'] ) ) { $selected_groups = $cachedSearch['groups']; } elseif ( is_array( $cachedSearch['clients'] ) ) { $selected_clients = $cachedSearch['clients']; } } static::render_header( 'BulkManage' ); ?>
', ' ' ); ?>
'mainwp_select_sites_box_left', 'selected_sites' => $selected_sites, 'selected_groups' => $selected_groups, 'selected_clients' => $selected_clients, 'show_client' => true, ); MainWP_UI_Select_Sites::select_sites_box( $sel_params ); ?>
render_demo_disable_button( '' ); } else { ?>
jQuery(function(){ mainwp_show_post( ' . intval( $_REQUEST['siteid'] ) . ', ' . intval( $_REQUEST['postid'] ) . ', undefined ) } );'; } elseif ( isset( $_REQUEST['siteid'] ) && isset( $_REQUEST['userid'] ) ) { echo ''; } // phpcs:enable // to fix issue js code display. $cachedSearch = MainWP_Cache::get_cached_context( 'Post' ); $statuses = isset( $cachedSearch['status'] ) ? $cachedSearch['status'] : array(); if ( is_array( $statuses ) && ! empty( $statuses ) ) { $status = ''; foreach ( $statuses as $st ) { $status .= "'" . esc_html( $st ) . "',"; } $status = rtrim( $status, ',' ); ?>

'true', 'paging' => 'true', 'info' => 'true', 'stateSave' => 'true', 'scrollX' => 'true', 'colReorder' => '{columns:":not(.check-column):not(:last-child)"}', 'order' => '[]', 'responsive' => 'true', ); /** * Filter: mainwp_posts_table_fatures * * Filters the Manage Posts table features. * * @since 4.1 */ $table_features = apply_filters( 'mainwp_posts_table_fatures', $table_features ); if ( $cached ) { ?> get_website_by_id( $v ); if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } } } if ( '' !== $groups ) { foreach ( $groups as $v ) { if ( MainWP_Utility::ctype_digit( $v ) ) { $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_by_group_id( $v ) ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } MainWP_DB::free_result( $websites ); } } } if ( '' !== $clients && is_array( $clients ) ) { $websites = MainWP_DB_Client::instance()->get_websites_by_client_ids( $clients, array( 'select_data' => $data_fields, ) ); foreach ( $websites as $website ) { if ( '' !== $website->sync_errors || MainWP_System_Utility::is_suspended_site( $website ) ) { continue; } $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data_fields ); } } $output = new \stdClass(); $output->errors = array(); $output->posts = 0; $output->table_rows = ''; if ( ! empty( $dbwebsites ) ) { $post_data = array( 'keyword' => $keyword, 'dtsstart' => $dtsstart, 'dtsstop' => $dtsstop, 'status' => $status, 'search_on' => $search_on, 'maxRecords' => ( ( false === get_option( 'mainwp_maximumPosts' ) ) ? 50 : get_option( 'mainwp_maximumPosts' ) ), ); if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) ) { $post_data['post_type'] = $post_type; if ( 'any' === $post_type ) { $post_data['exclude_page_type'] = 1; } } if ( MainWP_Utility::enabled_wp_seo() ) { $post_data['WPSEOEnabled'] = 1; } if ( isset( $postId ) && ( '' !== $postId ) ) { $post_data['postId'] = $postId; } elseif ( isset( $userId ) && ( '' !== $userId ) ) { $post_data['userId'] = $userId; } /** * Get all posts data * * Set search parameters for the fetch process. * * @since 3.4 */ $post_data = apply_filters( 'mainwp_get_all_posts_data', $post_data ); MainWP_Connect::fetch_urls_authed( $dbwebsites, 'get_all_posts', $post_data, array( static::get_class_name(), 'posts_search_handler', ), $output ); echo $output->table_rows; // phpcs:ignore WordPress.Security.EscapeOutput } if ( ! $table_content ) { MainWP_Cache::add_body( 'Post', $output->table_rows ); MainWP_Cache::add_context( 'Post', array( 'count' => $output->posts, 'keyword' => $keyword, 'dtsstart' => $dtsstart, 'dtsstop' => $dtsstop, 'status' => $status, 'sites' => ( '' !== $sites ) ? $sites : '', 'groups' => ( '' !== $groups ) ? $groups : '', 'clients' => ( '' !== $clients ) ? $clients : '', 'search_on' => $search_on, ) ); if ( 0 === $output->posts ) { MainWP_Cache::add_body( 'Post', '' ); } } } /** * Method get_status() * * Get Post status. * * @param mixed $status Post status. * * @return string $status Post status. */ private static function get_status( $status ) { if ( 'publish' === $status ) { return 'Published'; } return esc_html( ucfirst( $status ) ); } /** * Method posts_search_handler() * * Post page search handler. * * @param mixed $data Search data. * @param mixed $website Child Sites ID. * @param mixed $output Html to output. * * @return string Returned search results html. * * @uses \MainWP\Dashboard\MainWP_Cache::add_body() * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() * @uses \MainWP\Dashboard\MainWP_Exception * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response() * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() */ public static function posts_search_handler( $data, $website, &$output ) { // phpcs:ignore -- NOSONAR - complex method. if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) { return; } if ( 0 < preg_match( '/(.*)<\/mainwp>/', $data, $results ) ) { $result = $results[1]; $posts = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. if ( is_array( $posts ) && isset( $posts['error'] ) ) { $output->errors[ $website->id ] = esc_html( $posts['error'] ); return; } unset( $results ); $child_to_dash_array = array(); if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) ) { $child_post_ids = array(); foreach ( $posts as $post ) { $child_post_ids[] = $post['id']; } reset( $posts ); $connections_ids = apply_filters( 'mainwp_custom_post_types_get_post_connections', false, $website->id, $child_post_ids ); if ( ! empty( $connections_ids ) ) { foreach ( $connections_ids as $key ) { $child_to_dash_array[ $key->child_post_id ] = $key->dash_post_id; } } } $table_rows = ''; foreach ( $posts as $post ) { $raw_dts = ''; if ( isset( $post['dts'] ) ) { $raw_dts = $post['dts']; if ( ! stristr( $post['dts'], '-' ) ) { $post['dts'] = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $post['dts'] ) ); } } if ( ! isset( $post['title'] ) || ( '' === $post['title'] ) ) { $post['title'] = '(No Title)'; } ob_start(); ?>
url ); ?> posts; } $output->table_rows .= $table_rows; unset( $posts ); } else { $output->errors[ $website->id ] = MainWP_Error_Helper::get_error_message( new MainWP_Exception( 'NOMAINWP', $website->url ) ); } } /** * Method list_meta_row() * * Outputs a single row of public meta data in the Custom Fields meta box. * * @since 2.5.0 * * @param array $entry Post array. * @param int $count Counter variable. * * @return string $r Custom Fields meta box HTML. * * @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze() */ public static function list_meta_row( $entry, &$count ) { /** * Static variable to hold update nonce. * * @static * * @var string Update nonce. */ static $update_nonce = ''; if ( is_protected_meta( $entry['meta_key'], 'post' ) ) { return ''; } if ( ! $update_nonce ) { $update_nonce = wp_create_nonce( 'add-meta' ); } $r = ''; ++$count; if ( is_serialized( $entry['meta_value'] ) ) { if ( is_serialized_string( $entry['meta_value'] ) ) { $entry['meta_value'] = MainWP_System_Utility::maybe_unserialyze( $entry['meta_value'] ); //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- ok. } else { --$count; return ''; } } $entry['meta_key'] = esc_attr( $entry['meta_key'] ); //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- ok. $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- ok. $entry['meta_id'] = (int) $entry['meta_id']; $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t
'; $r .= "\n\t\t
"; $r .= "\n\t\t"; $r .= "'; $r .= "\n\t\t"; $r .= "'; $r .= '
'; $r .= "\n\t\t
\n\t
"; return $r; } /** * Method meta_form() * * Prints the form in the Custom Fields meta box. * * @since 1.2.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param WP_Post $pos Optional. The post being edited. */ public static function meta_form( $pos = null ) { global $wpdb; $_post = get_post( $pos ); /** * Filters values for the meta key dropdown in the Custom Fields meta box. * * Returning a non-null value will effectively short-circuit and avoid a * potentially expensive query against postmeta. * * @since 4.4.0 * * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null. * @param WP_Post $_post The current post object. */ $keys = apply_filters( 'postmeta_form_keys', null, $_post ); if ( null === $keys ) { /** * Filters the number of custom fields to retrieve for the drop-down * in the Custom Fields meta box. * * @since 2.1.0 * * @param int $limit Number of custom fields to retrieve. Default 30. */ $limit = apply_filters( 'postmeta_form_limit', 30 ); $sql = "SELECT DISTINCT meta_key FROM $wpdb->postmeta WHERE meta_key NOT BETWEEN '_' AND '_z' HAVING meta_key NOT LIKE %s ORDER BY meta_key LIMIT %d"; $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); // phpcs:ignore -- unprepared SQL ok. } if ( $keys ) { natcasesort( $keys ); $meta_key_input_id = 'metakeyselect'; } else { $meta_key_input_id = 'metakeyinput'; } ?>
ID ); foreach ( $metadata as $key => $value ) { if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) { unset( $metadata[ $key ] ); } } $count = 0; if ( $metadata ) { foreach ( $metadata as $entry ) { echo static::list_meta_row( $entry, $count ); // phpcs:ignore WordPress.Security.EscapeOutput } } static::meta_form( $post ); ?>
post_type ); $thumb_ok = false; $upload_iframe_src = get_upload_iframe_src( 'image', $_post->ID ); if ( $thumbnail_id && get_post( $thumbnail_id ) ) { $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); /** * Filters the size used to display the post thumbnail image in the 'Featured Image' meta box. * * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail' * image size is registered, which differs from the 'thumbnail' image size * managed via the Settings > Media screen. See the `$size` parameter description * for more information on default values. * * @since 4.4.0 * * @param string|array $size Post thumbnail image size to display in the meta box. Accepts any valid * image size, or an array of width and height values in pixels (in that order). * If the 'post-thumbnail' size is set, default is 'post-thumbnail'. Otherwise, * default is an array with 266 as both the height and width values. * @param int $thumbnail_id Post thumbnail attachment ID. * @param WP_Post $_post The post object associated with the thumbnail. */ $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $_post ); $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); if ( ! empty( $thumbnail_html ) ) { $thumb_ok = true; $set_thumbnail_link = '

%s

'; $content = '
'; $content .= sprintf( $set_thumbnail_link, esc_url( $upload_iframe_src ), ' aria-describedby="set-post-thumbnail-desc"', $thumbnail_html ); $content .= '

' . esc_html__( 'Click the image to edit or update', 'mainwp' ) . '

'; $content .= '

' . esc_html( $post_type_object->labels->remove_featured_image ) . '

'; $content .= '
'; } } if ( ! $thumb_ok ) { $set_thumbnail_link = '

%s

'; $content = sprintf( $set_thumbnail_link, esc_url( $upload_iframe_src ), '', esc_html( $post_type_object->labels->set_featured_image ) ); } $content .= ''; $html = '
'; $html .= '
' . esc_html__( 'Featured Image', 'mainwp' ) . '
'; $html .= '
ID, $thumbnail_id ); } /** * Method post_thumbnail_meta_box() * * Renders the post thumbnail meta box. * * @param mixed $pos Post ID. */ public static function post_thumbnail_meta_box( $pos ) { $thumbnail_id = get_post_meta( $pos->ID, '_thumbnail_id', true ); echo static::wp_post_thumbnail_html( $thumbnail_id, $pos->ID ); // phpcs:ignore WordPress.Security.EscapeOutput } /** * Method touch_time() * * Add time stamps to Post for screen readers. * * @param object $post Current Post object. * @param integer $edit Whether or not this is an edit or new post. * @param integer $for_post For post. * @param integer $tab_index Tabindex position. * @param integer $multi Multi. * * @return string Hidden time stamps html. */ public static function touch_time( $post, $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { //phpcs:ignore -- NOSONAR - complex method. /** * WordPress Locale. * * @global string */ global $wp_locale; $_post = get_post( $post ); if ( $for_post ) { $edit = ! ( in_array( $_post->post_status, array( 'draft', 'pending' ) ) && ( ! $_post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) ); } $tab_index_attribute = ''; if ( 0 < (int) $tab_index ) { $tab_index_attribute = " tabindex=\"$tab_index\""; } $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date; $jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' ); $mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' ); $aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' ); $hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' ); $mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' ); $ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' ); $cur_jj = current_time( 'd' ); $cur_mm = current_time( 'm' ); $cur_aa = current_time( 'Y' ); $cur_hh = current_time( 'H' ); $cur_mn = current_time( 'i' ); $month = ''; $day = ''; $year = ''; $hour = ''; $minute = ''; echo '
'; printf( esc_html__( '%1$s %2$s, %3$s @ %4$s:%5$s', 'mainwp' ), $month, $day, $year, $hour, $minute ); // phpcs:ignore WordPress.Security.EscapeOutput echo '
'; if ( $multi ) { return; } echo "\n\n"; $map = array( 'mm' => array( $mm, $cur_mm ), 'jj' => array( $jj, $cur_jj ), 'aa' => array( $aa, $cur_aa ), 'hh' => array( $hh, $cur_hh ), 'mn' => array( $mn, $cur_mn ), ); foreach ( $map as $timeunit => $value ) { list( $unit, $curr ) = $value; echo '' . "\n"; $cur_timeunit = 'cur_' . $timeunit; echo '' . "\n"; } } /** * Method do_meta_boxes() * * Render meta boxes. * * @param mixed $screen Current page tab. * @param mixed $context Context. * @param mixed $input_obj Object. * * @return string Metabox html */ public static function do_meta_boxes( $screen, $context, $input_obj ) { // phpcs:ignore -- NOSONAR - current complexity required to achieve desired results. Purll Request solutions appreciated. /** * WordPress Meta Boxes array. * * @global object */ global $wp_meta_boxes; static $already_sorted = false; if ( empty( $screen ) ) { $screen = get_current_screen(); } elseif ( is_string( $screen ) ) { $screen = convert_to_screen( $screen ); } $page = $screen->id; if ( 'mainwp_page_PostBulkAdd' === $page || 'mainwp_page_PostBulkEdit' === $page ) { $page = 'bulkpost'; } elseif ( 'mainwp_page_PageBulkAdd' === $page || 'mainwp_page_PageBulkEdit' === $page ) { $page = 'bulkpage'; } if ( ! is_array( $wp_meta_boxes ) || empty( $wp_meta_boxes[ $page ][ $context ] ) ) { return; } printf( '
', esc_attr( $context ) ); $sorted = get_user_option( "meta-box-order_$page" ); if ( ! $already_sorted && $sorted ) { foreach ( $sorted as $widget_context => $ids ) { foreach ( explode( ',', $ids ) as $id ) { if ( $id && 'dashboard_browser_nag' !== $id ) { add_meta_box( $id, null, null, $screen, $widget_context, 'sorted' ); } } } } $already_sorted = true; $i = 0; if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { if ( false === $box || ! isset( $box['title'] ) ) { continue; } $block_compatible = true; if ( isset( $box['args'] ) && is_array( $box['args'] ) ) { if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) { continue; } if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) { $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box']; unset( $box['args']['__block_editor_compatible_meta_box'] ); } if ( ! $block_compatible && $screen->is_block_editor() ) { $box['old_callback'] = $box['callback']; $box['callback'] = 'do_block_editor_incompatible_meta_box'; } if ( isset( $box['args']['__back_compat_meta_box'] ) ) { $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box']; unset( $box['args']['__back_compat_meta_box'] ); } } ++$i; echo '
' . "\n"; if ( 'dashboard_browser_nag' !== $box['id'] && isset( $box['args'] ) && is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { unset( $box['args']['__widget_basename'] ); } $title = $box['title']; if ( empty( $box['metabox-custom'] ) && ! empty( $title ) ) { $title = '{' . $title . '}'; } echo '

' . esc_html( $title ) . "

\n"; echo '
' . "\n"; // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( defined( 'WP_DEBUG' ) && WP_DEBUG && empty( $box['metabox-custom'] ) && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) { $plugin = _get_plugin_from_callback( $box['callback'] ); if ( $plugin ) { ?>

{' . esc_html( $plugin['Name'] ) . '}' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>

\n"; echo "
\n"; } } } } echo '
'; return $i; } /** * Renders bulkpost to edit. * * @param mixed $post_id Post ID. * @param mixed $input_type Post type. * * @return string Edit bulk post html. * * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_slug() * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_tags() * @uses \MainWP\Dashboard\MainWP_UI */ public static function render_bulkpost( $post_id, $input_type ) { //phpcs:ignore -- NOSONAR - complex method. $post = get_post( $post_id ); if ( $post ) { $post_type = $post->post_type; $post_type_object = get_post_type_object( $post_type ); } if ( ! $post_type_object || $input_type !== $post_type || ( 'bulkpost' !== $post_type && 'bulkpage' !== $post_type ) ) { esc_html_e( 'Invalid post type.', 'mainwp' ); return; } // to support custom render bulkpost. $custom_posting = apply_filters( 'mainwp_custom_render_bulkpost', false, $post_id, $post_type ); if ( $custom_posting ) { return; } $post_ID = $post->ID; $GLOBAL['bulkpost_edit'] = $post; /** * Current user global. * * @global string */ global $current_user; $user_ID = $current_user->ID; $_content_editor_dfw = false; $is_IE = false; $_wp_editor_expand = true; $form_action = 'mainwp_editpost'; $nonce_action = 'update-post_' . $post_ID; $form_extra = ""; $referer = wp_get_referer(); // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( isset( $_GET['boilerplate'] ) ) { if ( 'auto-draft' === $post->post_status ) { $note_title = ( 'bulkpost' === $post_type ) ? esc_html__( 'Create New Boilerplate Post', 'mainwp' ) : esc_html__( 'Create New Boilerplate Page', 'mainwp' ); } else { $note_title = ( 'bulkpost' === $post_type ) ? esc_html__( 'Edit Boilerplate Post', 'mainwp' ) : esc_html__( 'Edit Boilerplate Page', 'mainwp' ); } } elseif ( 'auto-draft' === $post->post_status ) { $note_title = ( 'bulkpost' === $post_type ) ? esc_html__( 'Create New Bulk Post', 'mainwp' ) : esc_html__( 'Create New Bulk Page', 'mainwp' ); } else { $note_title = ( 'bulkpost' === $post_type ) ? esc_html__( 'Edit Bulk Post', 'mainwp' ) : esc_html__( 'Edit Bulk Page', 'mainwp' ); } $note_title = apply_filters( 'mainwp_bulkpost_edit_title', $note_title, $post ); $message = ''; if ( isset( $_GET['message'] ) && 1 === (int) $_GET['message'] ) { if ( 'bulkpost' === $post_type ) { $message = esc_html__( 'Post updated.', 'mainwp' ); } else { $message = esc_html__( 'Page updated.', 'mainwp' ); } } // phpcs:enable ?>
', ' ' ); ?> ', ' ' ); ?>

$_content_editor_dfw, 'drag_drop_upload' => true, 'tabfocus_elements' => 'content-html,save-post', 'editor_height' => 300, 'quicktags' => true, 'media_buttons' => true, 'tinymce' => array( 'resize' => false, 'wp_autoresize_on' => $_wp_editor_expand, 'add_unload_trigger' => false, 'wp_keep_scroll_position' => ! $is_IE, ), ); $ed_settings = apply_filters( 'mainwp_bulkpost_editor_settings', false, $post ); if ( is_array( $ed_settings ) && ! empty( $ed_settings ) ) { $ed_settings = array_merge( $default_settings, $ed_settings ); } else { $ed_settings = $default_settings; } remove_editor_styles(); wp_editor( $post->post_content, 'content', $ed_settings ); ?>
0' ); ?>   post_status ) { echo ''; $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ); if ( $last_user ) { printf( esc_html__( 'Last edited by %1$s on %2$s at %3$s', 'mainwp' ), esc_html( $last_user->display_name ), mysql2date( esc_html__( 'F j, Y' ), $post->post_modified ), mysql2date( esc_html__( 'g:i a' ), $post->post_modified ) ); // phpcs:ignore WordPress.Security.EscapeOutput } else { printf( esc_html__( 'Last edited on %1$s at %2$s', 'mainwp' ), mysql2date( esc_html__( 'F j, Y' ), $post->post_modified ), mysql2date( esc_html__( 'g:i a' ), $post->post_modified ) ); // phpcs:ignore WordPress.Security.EscapeOutput } echo ''; } ?>
metaboxes->add_slug( $post ); ?>
metaboxes->add_tags( $post ); ?>
'checkbox', 'show_group' => true, 'show_select_all' => true, 'class' => '', 'style' => '', ); $sites_settings = array(); $sites_settings = apply_filters( 'mainwp_bulkpost_select_sites_settings', $sites_settings, $post ); if ( is_array( $sites_settings ) && ! empty( $sites_settings ) ) { $sites_settings = array_merge( $sites_default, $sites_settings ); } else { $sites_settings = $sites_default; } $sel_sites = array(); $sel_groups = array(); ?>
$sites_settings['type'], 'show_group' => $sites_settings['show_group'], 'show_select_all' => $sites_settings['show_select_all'], 'class' => $sites_settings['class'], 'style' => $sites_settings['style'], 'selected_sites' => $sel_sites, 'selected_groups' => $sel_groups, 'post_id' => $post_ID, 'show_client' => true, ); MainWP_UI_Select_Sites::select_sites_box( $sel_params ); ?>
render_demo_disable_button( '' ); } else { ?>
ID, '_categories', true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. $categories = explode( ',', $categories ); } if ( ! is_array( $categories ) ) { $categories = array(); } $uncat = esc_html__( 'Uncategorized', 'mainwp' ); $post_only = false; if ( $post ) { $post_only = get_post_meta( $post->ID, '_post_to_only_existing_categories', true ); } ?>
>
ID, '_categories', true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. $categories = explode( ',', $categories ); } if ( ! is_array( $categories ) ) { $categories = array(); } $uncat = esc_html__( 'Uncategorized', 'mainwp' ); $post_only = false; if ( $post ) { $post_only = get_post_meta( $post->ID, '_post_to_only_existing_categories', true ); } ?>
>
'; ?> '; ?>
comment_status, 'open' ); ?>>
ping_status, 'open' ); ?> >
post_status ) { $post->post_password = ''; $visibility = 'private'; } elseif ( ! empty( $post->post_password ) ) { $visibility = 'password'; } elseif ( 'bulkpost' === $post_type && is_sticky( $post->ID ) ) { $visibility = 'public'; } else { $visibility = 'public'; } ?>
>
ID ) ); ?> />
>
>
>
post_status ) ? '' : 'style="display:none"'; ?>>
ID : 0; static::render_addedit( $post_id, 'BulkAdd' ); } /** * Method render_bulk_edit() * * Check if user has rights, * render the bulk edit tab. * * @return string Bulk edit tab html. */ public static function render_bulk_edit() { if ( ! \mainwp_current_user_can( 'dashboard', 'manage_posts' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage posts', 'mainwp' ) ); return; } // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : 0; // phpcs:enable static::render_addedit( $post_id, 'BulkEdit' ); } /** * Method render_bulk_addedit() * * Render both the Add & Edit tabs. * * @param mixed $post_id post ID. * @param mixed $what what tab is active. */ public static function render_addedit( $post_id, $what ) { static::render_header( $what, $post_id ); static::render_bulkpost( $post_id, 'bulkpost' ); static::render_footer( $what ); } /** * Method hook_posts_search_handler() * * Hook Posts Search handler. * * @param mixed $data search data. * @param object $website child site object. * @param mixed $output output. * * @uses \MainWP\Dashboard\MainWP_System_Utility::get_child_response() */ public static function hook_posts_search_handler( $data, $website, &$output ) { $posts = array(); if ( 0 < preg_match( '/(.*)<\/mainwp>/', $data, $results ) ) { $result = $results[1]; $posts = MainWP_System_Utility::get_child_response( base64_decode( $result ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible. unset( $results ); } $output->results[ $website->id ] = $posts; } /** * Method mainwp_help_content() * * Creates the MainWP Help Documentation List for the help component in the sidebar. */ public static function mainwp_help_content() { // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( isset( $_GET['page'] ) && ( 'PostBulkManage' === $_GET['page'] || 'PostBulkAdd' === $_GET['page'] ) ) { ?>

* * @since 4.1 */ do_action( 'mainwp_posts_help_item' ); ?>