Adding a column in the media list page (no action yet)
This commit is contained in:
1 parent
7d744a1f1c
commit
7d8beefebf
2 files changed
+43
-79
No files matched your search
+43
-10
@@ -1,21 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* vim: set ai sw=4 smarttab expandtab: tabstop=8 softtabstop=0
|
||||
*
|
||||
* Plugin Name: WP PDF Helper
|
||||
* Description: Helps to print pages and posts as PDF
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
add_filter('manage_media_columns', 'add_media_column', 50, 2);
|
||||
function add_media_column($columns, $detached) {
|
||||
# error_log('PHP: $columns: '.print_r($columns, true), 0);
|
||||
$keys = array_keys($columns);
|
||||
$columns_updated = [];
|
||||
foreach ($keys as $key) {
|
||||
$columns_updated[$key] = $columns[$key];
|
||||
if ($key == 'parent') {
|
||||
$columns_updated['wp-pdf-helper'] = 'Print';
|
||||
}
|
||||
}
|
||||
# $actions['download'] = '<a href="' . wp_get_attachment_url($post->ID) . '">Download</a>';
|
||||
return $columns_updated;
|
||||
}
|
||||
|
||||
add_action('manage_media_custom_column', 'manage_custom_columns', 10, 2);
|
||||
|
||||
function manage_custom_columns ($column_key, $post_id) {
|
||||
if ($column_key == 'wp-pdf-helper') {
|
||||
$checked = (get_post_meta($post_id, 'wpdfh.print', true) == '') ? '' : 'checked';
|
||||
echo "<input type='checkbox' name='Print' value='always' $checked />";
|
||||
error_log("PHP: \$column_key: $column_key, \$post_id: $post_id, \$is_printable: $is_printable.", 0);
|
||||
}
|
||||
}
|
||||
|
||||
add_action('admin_enqueue_scripts', 'wpdfh_enqueue_admin_scripts');
|
||||
function wpdfh_enqueue_admin_scripts() {
|
||||
wp_enqueue_style( 'wpdfh-admin', plugin_dir_url( __FILE__ ) . 'assets/wp-pdf-helper-admin.css' );
|
||||
}
|
||||
|
||||
if ( ! array_key_exists('print', $_GET)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'wpdfh_enqueue_scripts');
|
||||
function wpdfh_enqueue_scripts() {
|
||||
wp_enqueue_style( 'wpdfh', plugin_dir_url( __FILE__ ) . 'assets/wp-pdf-helper.css' );
|
||||
add_action('wp_enqueue_scripts', 'wpdfh_enqueue_print_scripts');
|
||||
function wpdfh_enqueue_print_scripts() {
|
||||
wp_enqueue_style( 'wpdfh-print', plugin_dir_url( __FILE__ ) . 'assets/wp-pdf-helper-print.css' );
|
||||
}
|
||||
|
||||
#error_log("PHP: parse_url($url, PHP_URL_QUERY): ".print_r(parse_url($url, PHP_URL_QUERY), true), 0);
|
||||
@@ -24,10 +57,10 @@ function wpdfh_enqueue_scripts() {
|
||||
add_filter( 'wpagpx_shortcode_parameters', 'filter_shortcode_parameters' );
|
||||
|
||||
function filter_shortcode_parameters($parameters) {
|
||||
$parameters['mheight'] = '200px';
|
||||
$parameters['gheight'] = '150px';
|
||||
$parameters['download'] = 'false';
|
||||
$parameters['attachments'] = 'false';
|
||||
return $parameters;
|
||||
$parameters['mheight'] = '200px';
|
||||
$parameters['gheight'] = '150px';
|
||||
$parameters['download'] = 'false';
|
||||
$parameters['attachments'] = 'false';
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user