/** * Outputs the contents of a specific column. * * @since 4.6.0 * @param string $column The column-key (defined in post_columns above). * @param int $post_id The ID of the popup. */ public static function post_column_content($column, $post_id) { $popup = IncPopupDatabase::get($post_id); switch ($column) { case 'po_name': $can_edit = current_user_can('edit_post', $post_id) && 'trash' !== $popup->status; $post_type_object = get_post_type_object(IncPopupItem::POST_TYPE); $actions = array(); if ($can_edit) { $actions['edit'] = array('url' => get_edit_post_link($post_id), 'title' => __('Edit this PopUp', PO_LANG), 'attr' => '', 'label' => __('Edit', PO_LANG)); } if ($can_edit && 'active' === $popup->status) { $the_url = 'edit.php?post_type=%1$s&post_id=%2$s&action=deactivate'; $the_url = admin_url(sprintf($the_url, IncPopupItem::POST_TYPE, $post_id)); $the_url = wp_nonce_url($the_url, 'deactivate-post_' . $post_id); $actions['deactivate'] = array('url' => $the_url, 'title' => __('Deactivate this PopUp', PO_LANG), 'attr' => '', 'label' => __('Deactivate', PO_LANG)); } if ($can_edit && 'inactive' === $popup->status) { $the_url = 'edit.php?post_type=%1$s&post_id=%2$s&action=activate'; $the_url = admin_url(sprintf($the_url, IncPopupItem::POST_TYPE, $post_id)); $the_url = wp_nonce_url($the_url, 'activate-post_' . $post_id); $actions['activate'] = array('url' => $the_url, 'title' => __('Activate this PopUp', PO_LANG), 'attr' => '', 'label' => __('Activate', PO_LANG)); } $actions['popup_preview'] = array('url' => '#', 'title' => __('Preview this PopUp', PO_LANG), 'attr' => 'class="po-preview" data-id="' . $post_id . '"', 'label' => __('Preview', PO_LANG)); if (current_user_can('delete_post', $post_id)) { if ('trash' === $popup->status) { $the_url = $post_type_object->_edit_link . '&action=untrash'; $the_url = admin_url(sprintf($the_url, $post_id)); $the_url = wp_nonce_url($the_url, 'untrash-post_' . $post_id); $actions['untrash'] = array('url' => $the_url, 'title' => __('Restore this PopUp from the Trash', PO_LANG), 'attr' => '', 'label' => __('Restore', PO_LANG)); } elseif (EMPTY_TRASH_DAYS) { $actions['trash'] = array('url' => get_delete_post_link($post_id), 'title' => __('Move this PopUp to the Trash', PO_LANG), 'attr' => 'class="submitdelete"', 'label' => __('Trash', PO_LANG)); } if ('trash' === $popup->status || !EMPTY_TRASH_DAYS) { $actions['delete'] = array('url' => get_delete_post_link($post_id, '', true), 'title' => __('Delete this PopUp permanently', PO_LANG), 'attr' => 'class="submitdelete"', 'label' => __('Delete Permanently', PO_LANG)); } } if ($can_edit) { ?> <a href="<?php echo esc_url(get_edit_post_link($post_id)); ?> " title="<?php _e('Edit this PopUp', PO_LANG); ?> "> <span class="the-title"><?php echo esc_html($popup->name); ?> </span> </a> <?php } else { ?> <span class="the-title"><?php echo esc_html($popup->name); ?> </span> <?php } ?> <div class="row-actions"> <?php $action_count = count($actions); $i = 0; foreach ($actions as $action => $item) { $i += 1; $sep = $i == $action_count ? '' : ' | '; ?> <span class="<?php echo esc_attr($action); ?> "> <a href="<?php echo esc_url($item['url']); ?> " title="<?php echo esc_attr($item['title']); ?> " <?php echo '' . $item['attr']; ?> > <?php echo esc_html($item['label']); ?> </a><?php echo esc_html($sep); ?> </span> <?php } ?> </div> <?php break; case 'po_cond': $rule_count = 0; ?> <div class="rules"> <?php foreach ($popup->rule as $key) { ?> <?php $label = IncPopupItem::condition_label($key); ?> <?php if (empty($label)) { continue; } ?> <?php $rule_count += 1; ?> <span class="rule"><?php echo esc_html($label); ?> </span> <?php } ?> <?php if (!$rule_count) { ?> <span class="rule-always"><?php _e('Always Show PopUp', PO_LANG); ?> </span> <?php } ?> </div> <?php break; case 'po_pos': if ('trash' === $popup->status) { echo '-'; } else { $order = $popup->order; if (!is_numeric($order) || $order > 999999) { $order = ''; } ?> <span class="the-pos"><?php echo esc_html($order); ?> </span> <?php } break; case 'po_state': $title = $popup->status_label($popup->status); ?> <span title="<?php echo esc_attr($title); ?> "> <i class="status-icon dashicons"></i> </span> <?php break; } }