var array_ajax = { post_id : 0, nonce : "" }; array_ajax.nonce = "' . wp_create_nonce( 'array-ajax' ) . '"; array_ajax.post_id = "' . $post->ID . '"; '; wp_enqueue_script( 'array-admin', plugin_dir_url(__FILE__) . '/gallery-admin.js', array( 'jquery' ), true ); wp_enqueue_style( 'gallery-admin-styles', plugin_dir_url(__FILE__) . '/array-gallery.css', array(), '1.0.0', 'screen' ); } /** * Adds the Array Gallery meta box to supported post edit screens * * @since 1.0.0 */ function add_gallery_meta_box() { $screens = array( 'post', 'array-portfolio' ); foreach ( $screens as $screen ) { add_meta_box( 'array_gallery_meta_box', // $id __( 'Array Gallery', 'array-toolkit' ), // $title array( $this, 'show_gallery_meta_box' ), // $callback $screen, // $page 'normal', // $context 'high'); // $priority } } /** * Outputs the markup for the Array Gallery meta box * * @since 1.0.0 */ function show_gallery_meta_box() { global $post; $meta = get_post_meta( $post->ID, '_gallery_image_ids', true ); ?>

' . wp_get_attachment_image( $thumb, array( 32, 32 ) ) . ''; } } echo $thumbs_output; die(); } /** * Template tag for displaying the gallery * * @since 1.0.0 */ function array_gallery() { global $post, $wp_version; if ( version_compare( $wp_version, '3.5', '>=' ) ) { $image_ids = get_post_meta( $post->ID, '_gallery_image_ids', false ); $image_ids_array = $image_ids[0] . ","; $images = explode( ',', $image_ids_array, -1 ); } else { //find images in the content with "wp-image-{n}" in the class name preg_match_all('/]?class=["|\'][^"]*wp-image-([0-9]*)[^"]*["|\'][^>]*>/i', get_the_content(), $result); $exclude_imgs = $result[1]; //exclude thumbnail from slider if ( get_post_meta( $post->ID, 'thumbnail', true ) == 'exclude' ) { $feat_img = get_post_thumbnail_id( $post_id ); $exclude_imgs[] = $feat_img; } $args = array( 'order' => 'ASC', 'orderby' => 'date', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'exclude' => $exclude_imgs, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1, 'fields' => 'ids' ); $images = get_posts( $args ); } if ( $images ) { echo ""; } } }// class $array_toolkit_gallery = new Array_Toolkit_Gallery; /** * Displays a post's gallery */ function array_gallery() { return Array_Toolkit_Gallery::array_gallery(); }