public function display_rows()
    {
        global $post;
        add_filter('the_title', 'esc_html');
        while (have_posts()) {
            the_post();
            $user_can_edit = current_user_can('edit_post', $post->ID);
            if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') {
                continue;
            }
            $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other';
            $att_title = _draft_or_post_title();
            ?>
            <tr id="post-<?php 
            echo $post->ID;
            ?>
"
                class="<?php 
            echo trim(' author-' . $post_owner . ' status-' . $post->post_status);
            ?>
">
                <?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        ?>
                            <th scope="row" class="check-column">
                                <?php 
                        if ($user_can_edit) {
                            ?>
                                    <label class="screen-reader-text"
                                           for="cb-select-<?php 
                            the_ID();
                            ?>
"><?php 
                            echo sprintf(__('Select %s'), $att_title);
                            ?>
</label>
                                    <input type="checkbox" name="media[]" id="cb-select-<?php 
                            the_ID();
                            ?>
"
                                           value="<?php 
                            the_ID();
                            ?>
"/>
                                <?php 
                        }
                        ?>
                            </th>
                            <?php 
                        break;
                    case 'icon':
                        list($mime) = explode('/', $post->post_mime_type);
                        $attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style;
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        if ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true)) {
                            if ($this->is_trash || !$user_can_edit) {
                                echo $thumb;
                            } else {
                                ?>
                                        <a href="<?php 
                                echo get_edit_post_link($post->ID);
                                ?>
"
                                           title="<?php 
                                echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                                ?>
">
                                            <?php 
                                echo $thumb;
                                ?>
                                        </a>

                                    <?php 
                            }
                        }
                        ?>
                            </td>
                            <?php 
                        break;
                    case 'title':
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><strong>
                                    <?php 
                        if ($this->is_trash || !$user_can_edit) {
                            echo $att_title;
                        } else {
                            ?>
                                        <a href="<?php 
                            echo get_edit_post_link($post->ID);
                            ?>
"
                                           title="<?php 
                            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                            ?>
">
                                            <?php 
                            echo $att_title;
                            ?>
</a>
                                    <?php 
                        }
                        _media_states($post);
                        ?>
</strong>

                                <p class="filename"><?php 
                        echo wp_basename($post->guid);
                        ?>
</p>
                                <?php 
                        echo $this->row_actions($this->_get_row_actions($post, $att_title));
                        ?>
                            </td>
                            <?php 
                        break;
                    case 'author':
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')), get_the_author());
                        ?>
</td>
                            <?php 
                        break;
                    case 'desc':
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo has_excerpt() ? $post->post_excerpt : '';
                        ?>
</td>
                            <?php 
                        break;
                    case 'date':
                        if ('0000-00-00 00:00:00' == $post->post_date) {
                            $h_time = __('Unpublished');
                        } else {
                            $m_time = $post->post_date;
                            $time = get_post_time('G', true, $post, false);
                            if (abs($t_diff = time() - $time) < DAY_IN_SECONDS) {
                                if ($t_diff < 0) {
                                    $h_time = sprintf(__('%s from now'), human_time_diff($time));
                                } else {
                                    $h_time = sprintf(__('%s ago'), human_time_diff($time));
                                }
                            } else {
                                $h_time = mysql2date(__('Y/m/d'), $m_time);
                            }
                        }
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $h_time;
                        ?>
</td>
                            <?php 
                        break;
                    case 'parent':
                        if ($post->post_parent > 0) {
                            $parent = get_post($post->post_parent);
                        } else {
                            $parent = false;
                        }
                        if ($parent) {
                            $title = _draft_or_post_title($post->post_parent);
                            $parent_type = get_post_type_object($parent->post_type);
                            ?>
                                <td <?php 
                            echo $attributes;
                            ?>
><strong>
                                        <?php 
                            if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $post->post_parent)) {
                                ?>
                                        <a href="<?php 
                                echo get_edit_post_link($post->post_parent);
                                ?>
">
                                            <?php 
                                echo $title;
                                ?>
</a><?php 
                            } else {
                                echo $title;
                            }
                            ?>
</strong>,
                                    <?php 
                            echo get_the_time(__('Y/m/d'));
                            ?>
<br/>
                                    <?php 
                            if ($user_can_edit) {
                                $detach_url = add_query_arg(array('parent_post_id' => $post->post_parent, 'media[]' => $post->ID, '_wpnonce' => wp_create_nonce('bulk-' . $this->_args['plural'])), 'upload.php');
                                ?>
                                        <a class="hide-if-no-js detach-from-parent"
                                           href="<?php 
                                echo $detach_url;
                                ?>
"><?php 
                                _e('Detach');
                                ?>
</a>
                                    <?php 
                            }
                            ?>
                                </td>
                                <?php 
                        } else {
                            ?>
                                <td <?php 
                            echo $attributes;
                            ?>
><?php 
                            _e('(Unattached)');
                            ?>
<br/>
                                    <?php 
                            if ($user_can_edit) {
                                ?>
                                        <a class="hide-if-no-js"
                                           onclick="findPosts.open( 'media[]','<?php 
                                echo $post->ID;
                                ?>
' ); return false;"
                                           href="#the-list">
                                            <?php 
                                _e('Attach');
                                ?>
</a>
                                    <?php 
                            }
                            ?>
</td>
                                <?php 
                        }
                        break;
                    case 'comments':
                        $attributes = 'class="comments column-comments num"' . $style;
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
>
                                <div class="post-com-count-wrapper">
                                    <?php 
                        $pending_comments = get_pending_comments_num($post->ID);
                        $this->comments_bubble($post->ID, $pending_comments);
                        ?>
                                </div>
                            </td>
                            <?php 
                        break;
                    default:
                        if ('categories' == $column_name) {
                            $taxonomy = 'category';
                        } elseif ('tags' == $column_name) {
                            $taxonomy = 'post_tag';
                        } elseif (0 === strpos($column_name, 'taxonomy-')) {
                            $taxonomy = substr($column_name, 9);
                        } else {
                            $taxonomy = false;
                        }
                        if ($taxonomy) {
                            echo '<td ' . $attributes . '>';
                            if ($terms = get_the_terms($post->ID, $taxonomy)) {
                                $out = array();
                                foreach ($terms as $t) {
                                    $posts_in_term_qv = array();
                                    $posts_in_term_qv['taxonomy'] = $taxonomy;
                                    $posts_in_term_qv['term'] = $t->slug;
                                    $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg($posts_in_term_qv, 'upload.php')), esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')));
                                }
                                /* translators: used between list items, there is a space after the comma */
                                echo join(__(', '), $out);
                            } else {
                                echo '&#8212;';
                            }
                            echo '</td>';
                            break;
                        }
                        ?>
                            <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        /**
                         * Fires for each custom column in the Media list table.
                         *
                         * Custom columns are registered using the 'manage_media_columns' filter.
                         *
                         * @since 2.5.0
                         *
                         * @param string $column_name Name of the custom column.
                         * @param int $post_id Attachment ID.
                         */
                        do_action('manage_media_custom_column', $column_name, $post->ID);
                        ?>
</td>
                            <?php 
                        break;
                }
            }
            ?>
            </tr>
        <?php 
        }
    }
    function display_rows()
    {
        global $post, $id;
        add_filter('the_title', 'esc_html');
        $alt = '';
        while (have_posts()) {
            the_post();
            $user_can_edit = current_user_can('edit_post', $post->ID);
            if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') {
                continue;
            }
            $alt = 'alternate' == $alt ? '' : 'alternate';
            $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other';
            $att_title = _draft_or_post_title();
            ?>
	<tr id='post-<?php 
            echo $id;
            ?>
' class='<?php 
            echo trim($alt . ' author-' . $post_owner . ' status-' . $post->post_status);
            ?>
' valign="top">
<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        ?>
		<th scope="row" class="check-column">
			<?php 
                        if ($user_can_edit) {
                            ?>
				<input type="checkbox" name="media[]" value="<?php 
                            the_ID();
                            ?>
" />
			<?php 
                        }
                        ?>
		</th>
<?php 
                        break;
                    case 'icon':
                        $attributes = 'class="column-icon media-icon"' . $style;
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        if ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true)) {
                            if ($this->is_trash || !$user_can_edit) {
                                echo $thumb;
                            } else {
                                ?>
				<a href="<?php 
                                echo get_edit_post_link($post->ID, true);
                                ?>
" title="<?php 
                                echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                                ?>
">
					<?php 
                                echo $thumb;
                                ?>
				</a>

<?php 
                            }
                        }
                        ?>
		</td>
<?php 
                        break;
                    case 'title':
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><strong>
			<?php 
                        if ($this->is_trash || !$user_can_edit) {
                            echo $att_title;
                        } else {
                            ?>
			<a href="<?php 
                            echo get_edit_post_link($post->ID, true);
                            ?>
"
				title="<?php 
                            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                            ?>
">
				<?php 
                            echo $att_title;
                            ?>
</a>
			<?php 
                        }
                        _media_states($post);
                        ?>
</strong>
			<p>
<?php 
                        if (preg_match('/^.*?\\.(\\w+)$/', get_attached_file($post->ID), $matches)) {
                            echo esc_html(strtoupper($matches[1]));
                        } else {
                            echo strtoupper(str_replace('image/', '', get_post_mime_type()));
                        }
                        ?>
			</p>
<?php 
                        echo $this->row_actions($this->_get_row_actions($post, $att_title));
                        ?>
		</td>
<?php 
                        break;
                    case 'author':
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        the_author();
                        ?>
</td>
<?php 
                        break;
                    case 'tags':
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        $tags = get_the_tags();
                        if (!empty($tags)) {
                            $out = array();
                            foreach ($tags as $c) {
                                $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
                            }
                            echo join(', ', $out);
                        } else {
                            _e('No Tags');
                        }
                        ?>
		</td>
<?php 
                        break;
                    case 'desc':
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo has_excerpt() ? $post->post_excerpt : '';
                        ?>
</td>
<?php 
                        break;
                    case 'date':
                        if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) {
                            $t_time = $h_time = __('Unpublished');
                        } else {
                            $t_time = get_the_time(__('Y/m/d g:i:s A'));
                            $m_time = $post->post_date;
                            $time = get_post_time('G', true, $post, false);
                            if (abs($t_diff = time() - $time) < 86400) {
                                if ($t_diff < 0) {
                                    $h_time = sprintf(__('%s from now'), human_time_diff($time));
                                } else {
                                    $h_time = sprintf(__('%s ago'), human_time_diff($time));
                                }
                            } else {
                                $h_time = mysql2date(__('Y/m/d'), $m_time);
                            }
                        }
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $h_time;
                        ?>
</td>
<?php 
                        break;
                    case 'parent':
                        if ($post->post_parent > 0) {
                            if (get_post($post->post_parent)) {
                                $title = _draft_or_post_title($post->post_parent);
                            }
                            ?>
			<td <?php 
                            echo $attributes;
                            ?>
><strong>
				<?php 
                            if (current_user_can('edit_post', $post->post_parent)) {
                                ?>
					<a href="<?php 
                                echo get_edit_post_link($post->post_parent);
                                ?>
">
						<?php 
                                echo $title;
                                ?>
</a><?php 
                            } else {
                                echo $title;
                            }
                            ?>
</strong>,
				<?php 
                            echo get_the_time(__('Y/m/d'));
                            ?>
			</td>
<?php 
                        } else {
                            ?>
			<td <?php 
                            echo $attributes;
                            ?>
><?php 
                            _e('(Unattached)');
                            ?>
<br />
			<?php 
                            if ($user_can_edit) {
                                ?>
				<a class="hide-if-no-js"
					onclick="findPosts.open( 'media[]','<?php 
                                echo $post->ID;
                                ?>
' ); return false;"
					href="#the-list">
					<?php 
                                _e('Attach');
                                ?>
</a>
			<?php 
                            }
                            ?>
</td>
<?php 
                        }
                        break;
                    case 'comments':
                        $attributes = 'class="comments column-comments num"' . $style;
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
>
			<div class="post-com-count-wrapper">
<?php 
                        $pending_comments = get_pending_comments_num($post->ID);
                        $this->comments_bubble($post->ID, $pending_comments);
                        ?>
			</div>
		</td>
<?php 
                        break;
                    default:
                        ?>
		<td <?php 
                        echo $attributes;
                        ?>
>
			<?php 
                        do_action('manage_media_custom_column', $column_name, $id);
                        ?>
		</td>
<?php 
                        break;
                }
            }
            ?>
	</tr>
<?php 
        }
    }
    /**
     * Handles the title column output.
     *
     * @since 4.3.0
     * @access public
     *
     * @param WP_Post $post The current WP_Post object.
     */
    public function column_title($post)
    {
        list($mime) = explode('/', $post->post_mime_type);
        $title = _draft_or_post_title();
        $thumb = wp_get_attachment_image($post->ID, array(60, 60), true, array('alt' => ''));
        $link_start = $link_end = '';
        if (current_user_can('edit_post', $post->ID) && !$this->is_trash) {
            $link_start = '<a href="' . get_edit_post_link($post->ID) . '">';
            $link_end = '</a>';
        }
        $class = $thumb ? ' class="has-media-icon"' : '';
        ?>
		<strong<?php 
        echo $class;
        ?>
>
			<?php 
        echo $link_start;
        ?>
				<?php 
        if ($thumb) {
            ?>
				<span class="media-icon <?php 
            echo sanitize_html_class($mime . '-icon');
            ?>
"><?php 
            echo $thumb;
            ?>
</span>
				<?php 
        }
        ?>

				<span aria-hidden="true"><?php 
        echo $title;
        ?>
</span>
				<span class="screen-reader-text"><?php 
        printf(__('Edit &#8220;%s&#8221;'), $title);
        ?>
</span>
			<?php 
        echo $link_end;
        ?>
			<?php 
        _media_states($post);
        ?>
		</strong>
		<p class="filename"><span class="screen-reader-text"><?php 
        _e('File name:');
        ?>
 </span><?php 
        echo wp_basename($post->guid);
        ?>
</p>
		<?php 
    }
    /**
     * @since 4.3.0
     *
     * @param WP_Post $post
     */
    public function column_title($post)
    {
        list($mime) = explode('/', $post->post_mime_type);
        $user_can_edit = current_user_can('edit_post', $post->ID);
        $att_title = _draft_or_post_title();
        ?>
		<div class="media-icon <?php 
        echo $mime;
        ?>
-icon">
		<?php 
        $thumb = wp_get_attachment_image($post->ID, array(60, 60), true);
        if ($thumb) {
            if ($this->is_trash || !$user_can_edit) {
                echo $thumb;
            } else {
                ?>
			<a href="<?php 
                echo get_edit_post_link($post->ID);
                ?>
" title="<?php 
                echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                ?>
"><?php 
                echo $thumb;
                ?>
</a><?php 
            }
        }
        ?>
		</div>
		<div class="media-info">
			<strong>
			<?php 
        if ($this->is_trash || !$user_can_edit) {
            echo $att_title;
        } else {
            ?>
					<a href="<?php 
            echo get_edit_post_link($post->ID);
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
            ?>
"><?php 
            echo $att_title;
            ?>
</a><?php 
        }
        _media_states($post);
        ?>
			</strong>
			<p class="filename"><?php 
        echo wp_basename($post->guid);
        ?>
</p>
		</div>
		<?php 
    }
        function single_row($mode)
        {
            global $post, $original_post, $gllr_plugin_info, $wp_version;
            $attachment_metadata = wp_get_attachment_metadata($post->ID);
            if ($mode == 'grid') {
                $image_attributes = wp_get_attachment_image_src($post->ID, 'medium');
                ?>
				<li tabindex="0" id="post-<?php 
                echo $post->ID;
                ?>
" class="gllr-media-attachment">
					<div class="gllr-media-attachment-preview">
						<div class="gllr-media-thumbnail">
							<div class="centered">
								<img src="<?php 
                echo $image_attributes[0];
                ?>
" class="thumbnail" draggable="false" />
								<input type="hidden" name="_gallery_order_<?php 
                echo $original_post->ID;
                ?>
[<?php 
                echo $post->ID;
                ?>
]" value="<?php 
                echo get_post_meta($post->ID, '_gallery_order_' . $original_post->ID, true);
                ?>
" />
							</div>
						</div>
					</div>
					<a class="gllr-media-check" tabindex="-1" title="<?php 
                _e('Deselect', 'gallery-plugin');
                ?>
" href="#">
						<div class="media-modal-icon"></div>
					</a>
					<div class="gllr-media-attachment-details">
						<div class="gllr-media-attachment-info">						
							<div class="gllr-media-details">
								<div class="gllr-media-filename"><strong><?php 
                _e('File name', 'gallery-plugin');
                ?>
:</strong> <?php 
                the_title();
                ?>
</div>
								<div class="gllr-media-filetype"><strong><?php 
                _e('File type', 'gallery-plugin');
                ?>
:</strong> <?php 
                echo get_post_mime_type($post->ID);
                ?>
</div>
								<div class="gllr-media-dimensions"><strong><?php 
                _e('Dimensions', 'gallery-plugin');
                ?>
:</strong> <?php 
                echo $attachment_metadata['width'];
                ?>
 &times; <?php 
                echo $attachment_metadata['height'];
                ?>
</div>
							</div>
							<div class="gllr-media-actions">
								<a href="<?php 
                echo get_edit_post_link($post->ID);
                ?>
#TB_inline?width=800&height=450&inlineId=gllr-media-attachment-details-box-<?php 
                echo $post->ID;
                ?>
" class="thickbox" title="<?php 
                _e('Edit Attachment Info', 'gallery-plugin');
                ?>
"><?php 
                _e('Edit Attachment', 'gallery-plugin');
                ?>
</a>
							</div>
						</div>					
					</div>
					<div id="gllr-media-attachment-details-box-<?php 
                echo $post->ID;
                ?>
" class="gllr-media-attachment-details-box">
						<?php 
                $key = "gllr_image_text";
                $link_key = "gllr_link_url";
                $alt_tag_key = "gllr_image_alt_tag";
                $image_attributes = wp_get_attachment_image_src($post->ID, 'large');
                ?>
						<div class="gllr-pro-version-block">
							<a class="button bws_plugin_pro_version" href="http://bestwebsoft.com/products/gallery/?k=63a36f6bf5de0726ad6a43a165f38fe5&pn=79&v=<?php 
                echo $gllr_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
" target="_blank" title="<?php 
                _e('Go Pro', 'gallery-plugin');
                ?>
"><?php 
                _e('Pro version', 'gallery-plugin');
                ?>
								
							</a>
							<div class="gllr-pro-settings">
								<?php 
                _e('This setting is available in Pro version', 'gallery-plugin');
                ?>
								<img src="<?php 
                echo plugins_url('images/pro-settings.jpg', __FILE__);
                ?>
" alt="pro-settings" />
							</div>
						</div>
						<div class="gllr-media-attachment-details-box-left">
							<div class="gllr_border_image">
								<img src="<?php 
                echo $image_attributes[0];
                ?>
" alt="<?php 
                the_title();
                ?>
" title="<?php 
                the_title();
                ?>
" height="auto" width="<?php 
                echo $image_attributes[1];
                ?>
" />
							</div>
						</div>
						<div class="gllr-media-attachment-details-box-right">
							<div>
								<?php 
                _e("Title", 'gallery-plugin');
                ?>
								<div class="bws_help_box<?php 
                if ($wp_version >= '3.9') {
                    echo ' dashicons dashicons-editor-help';
                }
                ?>
"><div class="bws_hidden_help_text"><img src="<?php 
                echo plugins_url('gallery-plugin/images/image-title-example.png');
                ?>
" title="" alt=""/></div></div>
								<br />
								<input type="text" name="gllr_image_text[<?php 
                echo $post->ID;
                ?>
]" value="<?php 
                echo get_post_meta($post->ID, $key, true);
                ?>
" />
							</div>
							<div>
								<?php 
                _e("Alt tag", 'gallery-plugin');
                ?>
								<div class="bws_help_box<?php 
                if ($wp_version >= '3.9') {
                    echo ' dashicons dashicons-editor-help';
                }
                ?>
">
									<div class="bws_hidden_help_text" style="min-width: 130px;"><?php 
                _e('The alt attribute specifies an alternate text for an image, if the image cannot be displayed.', 'gallery-plugin');
                ?>
</div>
								</div>
								<br />
								<input type="text" name="gllr_image_alt_tag[<?php 
                echo $post->ID;
                ?>
]" value="<?php 
                echo get_post_meta($post->ID, $alt_tag_key, true);
                ?>
" />
							</div>
							<div>
								<?php 
                _e("Custom URL", 'gallery-plugin');
                ?>
								<div class="bws_help_box<?php 
                if ($wp_version >= '3.9') {
                    echo ' dashicons dashicons-editor-help';
                }
                ?>
">
									<div class="bws_hidden_help_text" style="min-width: 130px;"><?php 
                _e("By clicking on the thumbnail you'll go to the link (if the field is filled) or the image will be opened in the lightbox (if the field isn't filled)", 'gallery-plugin');
                ?>
</div>
								</div>
								<br />
								<input type="text" name="gllr_link_url[<?php 
                echo $post->ID;
                ?>
]" value="<?php 
                echo get_post_meta($post->ID, $link_key, true);
                ?>
" /><br />
							</div>
							<div class="gllr-media-attachment-actions">
								<a href="post.php?post=<?php 
                echo $post->ID;
                ?>
&amp;action=edit"><?php 
                _e('Edit more details', 'gallery-plugin');
                ?>
</a> 
								<span class="gllr-separator">|</span> 
								<a href="#" class="gllr-media-delete-attachment"><?php 
                _e('Delete from Gallery', 'gallery-plugin');
                ?>
</a>
								<input type="hidden" class="gllr_attachment_id" name="_gllr_attachment_id" value="<?php 
                echo $post->ID;
                ?>
" />
								<input type="hidden" class="gllr_post_id" name="_gllr_post_id" value="<?php 
                echo $original_post->ID;
                ?>
" />
							</div>
						</div>
						<div class="gllr_clear"></div>
					</div>
				</li>
			<?php 
            } else {
                $user_can_edit = current_user_can('edit_post', $post->ID);
                $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other';
                $att_title = _draft_or_post_title();
                ?>
				<tr id="post-<?php 
                echo $post->ID;
                ?>
" class="<?php 
                if ($wp_version < '4.3') {
                    echo 'gllr_add_responsive_column ';
                }
                echo trim(' author-' . $post_owner . ' status-' . $post->post_status);
                ?>
">
					<?php 
                list($columns, $hidden) = $this->get_column_info();
                foreach ($columns as $column_name => $column_display_name) {
                    $classes = "{$column_name} column-{$column_name}";
                    if (in_array($column_name, $hidden)) {
                        $classes .= ' hidden';
                    }
                    if ('title' == $column_name) {
                        $classes .= ' column-primary has-row-actions';
                    }
                    $attributes = "class='{$classes}'";
                    switch ($column_name) {
                        case 'order':
                            ?>
								<th <?php 
                            echo $attributes;
                            ?>
>
									<input type="hidden" name="_gallery_order_<?php 
                            echo $original_post->ID;
                            ?>
[<?php 
                            echo $post->ID;
                            ?>
]" value="<?php 
                            echo get_post_meta($post->ID, '_gallery_order_' . $original_post->ID, true);
                            ?>
" />
								</th>
								<?php 
                            break;
                        case 'cb':
                            ?>
								<th scope="row" class="check-column">
									<?php 
                            if ($user_can_edit) {
                                ?>
										<label class="screen-reader-text" for="cb-select-<?php 
                                the_ID();
                                ?>
"><?php 
                                echo sprintf(__('Select %s', 'gallery-plugin'), $att_title);
                                ?>
</label>
										<input type="checkbox" name="media[]" id="cb-select-<?php 
                                the_ID();
                                ?>
" value="<?php 
                                the_ID();
                                ?>
" />
									<?php 
                            }
                            ?>
								</th>
								<?php 
                            break;
                        case 'title':
                            ?>
								<td <?php 
                            echo $attributes;
                            ?>
><strong>
									<?php 
                            $thumb = wp_get_attachment_image($post->ID, array(80, 60), true);
                            if ($this->is_trash || !$user_can_edit) {
                                if ($thumb) {
                                    echo '<span class="media-icon image-icon">' . $thumb . '</span>';
                                }
                                echo '<span aria-hidden="true">' . $att_title . '</span>';
                            } else {
                                ?>
										<a href="<?php 
                                echo get_edit_post_link($post->ID);
                                ?>
" title="<?php 
                                echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'gallery-plugin'), $att_title));
                                ?>
">
											<?php 
                                if ($thumb) {
                                    echo '<span class="media-icon image-icon">' . $thumb . '</span>';
                                }
                                ?>
											<?php 
                                echo '<span aria-hidden="true">' . $att_title . '</span>';
                                ?>
										</a>
									<?php 
                            }
                            _media_states($post);
                            ?>
</strong>
									<p class="filename"><?php 
                            echo wp_basename($post->guid);
                            ?>
</p>
									<?php 
                            echo $this->row_actions($this->_get_row_actions($post, $att_title));
                            ?>
									<a href="#" class="gllr_info_show hidden"><?php 
                            _e('Edit Attachment Info', 'gallery-plugin');
                            ?>
</a>
								</td>
								<?php 
                            break;
                        case 'dimensions':
                            ?>
								<td <?php 
                            echo $attributes;
                            ?>
 data-colname="<?php 
                            _e('Dimensions', 'gallery-plugin');
                            ?>
">
									<?php 
                            echo $attachment_metadata['width'];
                            ?>
 &times; <?php 
                            echo $attachment_metadata['height'];
                            ?>
								</td>
								<?php 
                            break;
                        case 'gllr_image_text':
                            ?>
								<td <?php 
                            echo $attributes;
                            ?>
 data-colname="<?php 
                            _e('Title', 'gallery-plugin');
                            ?>
">
									<input type="text" name="<?php 
                            echo $column_name;
                            ?>
[<?php 
                            echo $post->ID;
                            ?>
]" value="<?php 
                            echo get_post_meta($post->ID, $column_name, true);
                            ?>
" />
								</td>
								<?php 
                            break;
                        case 'gllr_image_alt_tag':
                            ?>
								<td <?php 
                            echo $attributes;
                            ?>
 data-colname="<?php 
                            _e('Alt tag', 'gallery-plugin');
                            ?>
">
									<input type="text" name="<?php 
                            echo $column_name;
                            ?>
[<?php 
                            echo $post->ID;
                            ?>
]" value="<?php 
                            echo get_post_meta($post->ID, $column_name, true);
                            ?>
" />
								</td>
								<?php 
                            break;
                        case 'gllr_link_url':
                            ?>
								<td <?php 
                            echo $attributes;
                            ?>
 data-colname="<?php 
                            _e('Custom URL', 'gallery-plugin');
                            ?>
">
									<input type="text" name="<?php 
                            echo $column_name;
                            ?>
[<?php 
                            echo $post->ID;
                            ?>
]" value="<?php 
                            echo get_post_meta($post->ID, $column_name, true);
                            ?>
" />
								</td>
								<?php 
                            break;
                    }
                }
                ?>
				</tr>
			<?php 
            }
        }
    /**
     * Handles the title column output.
     *
     * @since 4.3.0
     * @access public
     *
     * @param WP_Post $post The current WP_Post object.
     */
    public function column_title($post)
    {
        list($mime) = explode('/', $post->post_mime_type);
        $title = _draft_or_post_title();
        $thumb = wp_get_attachment_image($post->ID, array(60, 60), true, array('alt' => ''));
        $link_start = $link_end = '';
        if (current_user_can('edit_post', $post->ID) && !$this->is_trash) {
            $link_start = sprintf('<a href="%s" aria-label="%s">', get_edit_post_link($post->ID), esc_attr(sprintf(__('&#8220;%s&#8221; (Edit)'), $title)));
            $link_end = '</a>';
        }
        $class = $thumb ? ' class="has-media-icon"' : '';
        ?>
		<strong<?php 
        echo $class;
        ?>
>
			<?php 
        echo $link_start;
        if ($thumb) {
            ?>
				<span class="media-icon <?php 
            echo sanitize_html_class($mime . '-icon');
            ?>
"><?php 
            echo $thumb;
            ?>
</span>
			<?php 
        }
        echo $title . $link_end;
        _media_states($post);
        ?>
		</strong>
		<p class="filename">
			<span class="screen-reader-text"><?php 
        _e('File name:');
        ?>
 </span>
			<?php 
        $file = get_attached_file($post->ID);
        echo esc_html(wp_basename($file));
        ?>
		</p>
		<?php 
    }
Example #7
0
    /**
     * Render the webcomic generator.
     * 
     * @uses Webcomic::$config
     * @uses Webcomic::get_attachments()
     */
    public function page_generator()
    {
        global $post;
        $attachments = self::get_attachments();
        $columns = '
			<tr>
				<th class="check-column"><input type="checkbox"></th>
				<th class="column-icon"></th>
				<th>' . __('File', "webcomic") . '</th>
			</tr>';
        ?>
		<div class="wrap">
			<div class="icon32" id="icon-upload"></div>
			<h2><?php 
        echo get_admin_page_title();
        ?>
</h2>
			<form method="post" class="webcomic-generator" data-webcomic-daycheck="<?php 
        esc_attr_e('The start date is not one of the selected publish days. Continue anyway?', "webcomic");
        ?>
">
				<?php 
        wp_nonce_field('webcomic_generate', 'webcomic_generate');
        ?>
				<div id="col-container">
					<div id="col-right">
						<div class="col-wrap">
							<table class="wp-list-table widefat fixed posts">
								<thead><?php 
        echo $columns;
        ?>
</thead>
								<tfoot><?php 
        echo $columns;
        ?>
</tfoot>
								<tbody>
									<?php 
        $i = 0;
        if ($attachments) {
            foreach ($attachments as $attachment) {
                $post = $attachment;
                ?>
									<tr<?php 
                echo $i % 2 ? '' : ' class="alternate"';
                ?>
>
										<th class="check-column"><input type="checkbox" name="attachments[]" id="attachment-<?php 
                echo $attachment->ID;
                ?>
" value="<?php 
                echo $attachment->ID;
                ?>
"></th>
										<td class="media-icon"><label for="attachment-<?php 
                echo $attachment->ID;
                ?>
"><?php 
                echo wp_get_attachment_image($attachment->ID, array(60, 60));
                ?>
</label></td>
										<td>
											<a href="<?php 
                echo esc_url(add_query_arg(array('post' => $attachment->ID, 'action' => 'edit'), admin_url('post.php')));
                ?>
"><span class="row-title"><?php 
                echo get_the_title($attachment->ID);
                ?>
</span></a><b><?php 
                _media_states($attachment);
                ?>
</b>
											<p><?php 
                echo preg_match('/^.*?\\.(\\w+)$/', get_attached_file($attachment->ID), $matches) ? esc_html(strtoupper($matches[1])) : strtoupper(str_replace('image/', '', get_post_mime_type($attachment->ID)));
                ?>
</p>
										</td>
									</tr>
									<?php 
                $i++;
            }
        } else {
            ?>
									<tr class="no-items">
										<td colspan="3"><?php 
            _e('No unattached media found.', "webcomic");
            ?>
</td>
									</tr>
									<?php 
        }
        ?>
								</tbody>
							</table>
						</div>
					</div>
					<div id="col-left">
						<div class="col-wrap">
							<div class="form-wrap">
								<label>
									<h3><?php 
        _e('Collection', "webcomic");
        ?>
</h3>
									<select name="webcomic_collection">
									<?php 
        foreach (self::$config['collections'] as $k => $v) {
            echo '<option value="', $k, '">', esc_html($v['name']), '</option>';
        }
        ?>
									</select>
								</label>
								<label>
									<h3><?php 
        _e('Start on&hellip;', "webcomic");
        ?>
</h3>
									<input type="date" name="webcomic_generate_start" value="<?php 
        echo date('Y-m-d');
        ?>
">
								</label>
								<h3><?php 
        _e('Publish every&hellip;', "webcomic");
        ?>
</h3>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="1"> <?php 
        _e('Monday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="2"> <?php 
        _e('Tuesday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="3"> <?php 
        _e('Wednesday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="4"> <?php 
        _e('Thursday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="5"> <?php 
        _e('Friday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="6"> <?php 
        _e('Saturday', "webcomic");
        ?>
</label>
								<label><input type="checkbox" name="webcomic_generate_days[]" value="7"> <?php 
        _e('Sunday', "webcomic");
        ?>
</label>
								<label><h3><input name="webcomic_generate_draft" type="checkbox"> <?php 
        _e('Save posts as drafts', "webcomic");
        ?>
</h3></label>
								<?php 
        submit_button(__('Generate Webcomics', "webcomic"));
        ?>
							</div>
						</div>
					</div>
				</div>
				<input type="hidden" name="webcomic_action" value="generate">
			</form>
		</div>
		<?php 
    }
    /**
     * Display for rows in table
     * @since 1.8
     * @uses object $post
     * @uses object $wpdb
     * @uses object $wpua_functions
     * @uses add_filter()
     * @uses _draft_or_post_title()
     * @uses _media_states()
     * @uses current_user_can()
     * @uses get_attached_file()
     * @uses get_current_user_id()
     * @uses get_edit_post_link()
     * @uses get_edit_user_link()
     * @uses get_post_mime_type()
     * @uses get_the_author()
     * @uses get_the_author_meta()
     * @uses get_userdata()
     * @uses have_posts()
     * @uses the_post()
     * @uses wpua_get_attachment_image()
     */
    public function display_rows()
    {
        global $post, $wpdb, $wpua_functions;
        add_filter('the_title', 'esc_html');
        $alt = "";
        while (have_posts()) {
            the_post();
            $user_can_edit = current_user_can('edit_post', $post->ID);
            if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') {
                continue;
            }
            $alt = 'alternate' == $alt ? "" : 'alternate';
            $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other';
            $att_title = _draft_or_post_title();
            ?>
    <tr id='post-<?php 
            echo $post->ID;
            ?>
' class='<?php 
            echo trim($alt . ' author-' . $post_owner . ' status-' . $post->post_status);
            ?>
' valign="top">
      <?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = "";
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        ?>
              <th scope="row" class="check-column">
                <?php 
                        if ($user_can_edit) {
                            ?>
                  <label class="screen-reader-text" for="cb-select-<?php 
                            the_ID();
                            ?>
"><?php 
                            echo sprintf(__('Select %s', 'wp-user-avatar'), $att_title);
                            ?>
</label>
                  <input type="checkbox" name="media[]" id="cb-select-<?php 
                            the_ID();
                            ?>
" value="<?php 
                            the_ID();
                            ?>
" />
                <?php 
                        }
                        ?>
              </th>
            <?php 
                        break;
                    case 'icon':
                        $attributes = 'class="column-icon media-icon"' . $style;
                        ?>
                <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        if ($thumb = $wpua_functions->wpua_get_attachment_image($post->ID, array(80, 60), true)) {
                            if ($this->is_trash || !$user_can_edit) {
                                echo $thumb;
                            } else {
                                ?>
                    <a href="<?php 
                                echo get_edit_post_link($post->ID, true);
                                ?>
" title="<?php 
                                echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                                ?>
">
                      <?php 
                                echo $thumb;
                                ?>
                    </a>
                  <?php 
                            }
                        }
                        ?>
                </td>
              <?php 
                        break;
                    case 'title':
                        ?>
        <td <?php 
                        echo $attributes;
                        ?>
><strong>
          <?php 
                        if ($this->is_trash || !$user_can_edit) {
                            echo $att_title;
                        } else {
                            ?>
          <a href="<?php 
                            echo get_edit_post_link($post->ID, true);
                            ?>
"
            title="<?php 
                            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title));
                            ?>
">
            <?php 
                            echo $att_title;
                            ?>
</a>
          <?php 
                        }
                        _media_states($post);
                        ?>
</strong>
          <p>
            <?php 
                        if (preg_match('/^.*?\\.(\\w+)$/', get_attached_file($post->ID), $matches)) {
                            echo esc_html(strtoupper($matches[1]));
                        } else {
                            echo strtoupper(str_replace('image/', "", get_post_mime_type()));
                        }
                        ?>
          </p>
          <?php 
                        echo $this->row_actions($this->_get_row_actions($post, $att_title));
                        ?>
        </td>
      <?php 
                        break;
                    case 'author':
                        ?>
        <td <?php 
                        echo $attributes;
                        ?>
>
          <?php 
                        printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')), get_the_author());
                        ?>
        </td>
      <?php 
                        break;
                    case 'date':
                        if ('0000-00-00 00:00:00' == $post->post_date) {
                            $h_time = __('Unpublished', 'wp-user-avatar');
                        } else {
                            $m_time = $post->post_date;
                            $time = get_post_time('G', true, $post, false);
                            if (abs($t_diff = time() - $time) < DAY_IN_SECONDS) {
                                if ($t_diff < 0) {
                                    $h_time = sprintf(__('%s from now', 'wp-user-avatar'), human_time_diff($time));
                                } else {
                                    $h_time = sprintf(__('%s ago', 'wp-user-avatar'), human_time_diff($time));
                                }
                            } else {
                                $h_time = mysql2date(__('Y/m/d', 'wp-user-avatar'), $m_time);
                            }
                        }
                        ?>
      <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $h_time;
                        ?>
</td>
      <?php 
                        break;
                    case 'parent':
                        global $blog_id, $wpdb;
                        // Find all users with this WPUA
                        $wpua_metakey = $wpdb->get_blog_prefix($blog_id) . 'user_avatar';
                        $wpuas = $wpdb->get_results($wpdb->prepare("SELECT wpum.user_id FROM {$wpdb->usermeta} AS wpum, {$wpdb->users} AS wpu WHERE wpum.meta_key = %s AND wpum.meta_value = %d AND wpum.user_id = wpu.ID ORDER BY wpu.user_login", $wpua_metakey, $post->ID));
                        // Find users without WPUA
                        $nowpuas = $wpdb->get_results($wpdb->prepare("SELECT wpu.ID FROM {$wpdb->users} AS wpu, {$wpdb->usermeta} AS wpum WHERE wpum.meta_key = %s AND wpum.meta_value = %d AND wpum.user_id = wpu.ID ORDER BY wpu.user_login", $wpua_metakey, ""));
                        $user_array = array();
                        ?>
        <td <?php 
                        echo $attributes;
                        ?>
>
          <strong>
          <?php 
                        if (!empty($wpuas)) {
                            foreach ($wpuas as $usermeta) {
                                $user = get_userdata($usermeta->user_id);
                                $user_array[] = '<a href="' . get_edit_user_link($user->ID) . '">' . $user->user_login . '</a>';
                            }
                        } else {
                            foreach ($nowpuas as $usermeta) {
                                $user = get_userdata($usermeta->ID);
                                $user_array[] = '<a href="' . get_edit_user_link($user->ID) . '">' . $user->user_login . '</a>';
                            }
                        }
                        ?>
          <?php 
                        echo implode(', ', array_filter($user_array));
                        ?>
          </strong>
        </td>
      <?php 
                        break;
                }
            }
            ?>
    </tr>
  <?php 
        }
    }