/** * Add actions * * @since 1.0.0 * @param array $actions The current actions * @param object $item The current item * @return array $actions The updated actions */ function edd_vault_dashboard_actions($actions, $item) { $type = false; // If this is a post, but not a download, bail if (property_exists($item, 'post_type')) { if ($item->post_type != 'download') { return $actions; } else { $type = 'download'; $id = $item->ID; $query = 'edit.php'; } } if (!$type) { $type = $item->taxonomy; $id = $item->term_id; $query = 'edit-tags.php'; } // Build the URL $stored = edd_vault_is_stored($id, $type); if ($stored[$type] == true) { $class = 'vault-remove'; $label = __('Remove From Vault', 'edd-vault'); $args = array('edd-action' => 'vault_remove', 'item_id' => $id, 'item_type' => $type); } else { $class = 'vault-add'; $label = __('Add To Vault', 'edd-vault'); $args = array('edd-action' => 'vault_add', 'item_id' => $id, 'item_type' => $type); } $url = esc_url(wp_nonce_url(add_query_arg($args), 'edd-vault-nonce')); $actions[$class] = '<a href="' . $url . '">' . $label . '</a>'; return $actions; }
/** * Add a notification bar for admins * * @since 1.0.0 * @param string $the_content The post content * @return string $the_content The updated post content */ function edd_vault_display_admin_notice($the_content) { if (isset($GLOBALS['post']) && $GLOBALS['post']->post_type == 'download') { $status = array_values(edd_vault_is_stored($GLOBALS['post']->ID)); if (in_array(true, $status)) { $the_content = '<div class="edd-vault-notice"><p>' . edd_get_option('vault_notice_text', sprintf(__('This %s is currently in the vault.', 'edd-vault'), edd_get_label_singular(true))) . '</p></div>' . $the_content; } } return $the_content; }
/** * Add status to stats meta box * * @since 1.0.0 * @global object $post The WordPress post object * @return void */ function edd_vault_stats_meta_box() { global $post; $status = edd_vault_is_stored($post->ID); if ($status['download']) { $download_status = ' edd-vault-status-stored'; $download_title = sprintf(__('%s Is In Vault', 'edd-vault'), edd_get_label_singular()); $button_title = __('Remove From Vault', 'edd-vault'); $button_args = array('edd-action' => 'vault_remove', 'item_id' => $post->ID, 'item_type' => 'download'); } else { $download_status = ''; $download_title = sprintf(__('%s Is Not In Vault', 'edd-vault'), edd_get_label_singular()); $button_title = __('Add To Vault', 'edd-vault'); $button_args = array('edd-action' => 'vault_add', 'item_id' => $post->ID, 'item_type' => 'download'); } if ($status['download_category']) { $download_category_status = ' edd-vault-status-stored'; $download_category_title = sprintf(__('%s Category Is In Vault', 'edd-vault'), edd_get_label_singular()); } else { $download_category_status = ''; $download_category_title = sprintf(__('%s Category Is Not In Vault', 'edd-vault'), edd_get_label_singular()); } if ($status['download_tag']) { $download_tag_status = ' edd-vault-status-stored'; $download_tag_title = sprintf(__('%s Tag Is In Vault', 'edd-vault'), edd_get_label_singular()); } else { $download_tag_status = ''; $download_tag_title = sprintf(__('%s Tag Is Not In Vault', 'edd-vault'), edd_get_label_singular()); } ?> <hr /> <p class="product-vault-status"> <span class="label"><?php _e('Vault Status:', 'edd-vault'); ?> </span> <span class="dashicons dashicons-download<?php echo $download_status; ?> " title="<?php echo $download_title; ?> "></span> <span class="dashicons dashicons-category<?php echo $download_category_status; ?> " title="<?php echo $download_category_title; ?> "></span> <span class="dashicons dashicons-tag<?php echo $download_tag_status; ?> " title="<?php echo $download_tag_title; ?> "></span> </p> <div class="product-vault-toggle"> <a class="button" href="<?php echo esc_url(wp_nonce_url(add_query_arg($button_args), 'edd-vault-nonce')); ?> "><?php echo $button_title; ?> </a> </div> <?php }
/** * Add vault status content (category/tag) * * @since 1.0.0 * @param string $c Null * @param string $column The column we are working with * @param int $id The item ID * @return void */ function edd_vault_dashboard_taxonomy_column_content($c, $column, $id) { switch ($column) { case 'vault-status': if ($_GET['taxonomy'] == 'download_category') { $title = sprintf(__('%s Category Is', 'edd-vault'), edd_get_label_singular()); $icon = 'category'; } else { $title = sprintf(__('%s Tag Is', 'edd-vault'), edd_get_label_singular()); $icon = 'tag'; } if (edd_vault_is_stored($id, $_GET['taxonomy'])) { $status = ' edd-vault-status-stored'; $title .= ' ' . __('In Vault', 'edd-vault'); } else { $status = ''; $title .= ' ' . __('Not In Vault', 'edd-vault'); } echo '<span class="dashicons dashicons-' . $icon . $status . '" title="' . $title . '"></span>'; break; } }