承接 voceconnect/voce-post-pdfs 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

voceconnect/voce-post-pdfs

Composer 安装命令:

composer require voceconnect/voce-post-pdfs

包简介

Generates PDF's from Posts

README 文档

README

Contributors: johnciacia, kevinlangleyjr, brockangelo
Tags: printing, pdf
Requires at least: 3.2
Tested up to: 3.8.3
Stable tag: 1.2.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

A WordPress plugin/module that generates a pdf from a post.

Description

This plugin generates a PDF file from a post's content using the PHP dompdf library. Simply link to the post + '/pdf/' and a PDF will be generated. You have the ability to customize the upload path, the PDF template that is used, and the filename format through filters.

Installation

As standard plugin:

See Installing Plugins.

As theme or plugin dependency:

After dropping the plugin into the containing theme or plugin, add the following:

if( ! class_exists( 'Voce_Post_PDFS' ) ) {
	require_once( $path_to_vpp . '/voce-post-pdfs.php' );
}

Usage

Add a Download PDF link to /pdf/:

$pdf_link = esc_url( trailingslashit( get_permalink() ) . 'pdf/' );

Customize with filters

To modify the logo used in the PDF header:

add_action( 'voce_post_pdfs_logo', function(){ 
  do_action('newsroom_custom_header_logo');
});

Use your own template for the PDF, relative to the theme directory:

add_filter('voce_post_pdf_print_template', function($template){
  return 'print.php';
});

Modify query args:

add_filter('voce_post_pdfs_save_query_args', function($args){
  if( isset( $_GET['lang'] ) )
     $args['lang'] = $_GET['lang'];
  return $args;
});

Modify the default filename format (defaults to post-title.pdf):

add_filter('voce_post_pdfs_save_filename', function($filename) {
  $lang = ( isset( $_GET['lang'] )  ? '-' . sanitize_key( $_GET['lang'] ) : '');
  $filename = basename($filename, '.pdf');
  return $filename . $lang . '.pdf';
});

Modify the upload location on the server:

add_filter('voce_post_pdfs_upload_basepath', function($basepath, $post){
  $uploads = wp_upload_dir();
  $basepath = $uploads['basedir'] . '/' . date('Y', strtotime($post->post_date) ) . '/' . date('m', strtotime($post->post_date) ) . '/pdf/';                
  return $basepath;
}, 10, 2);

Modify the url to the pdf:

add_filter('voce_post_pdfs_upload_baseurl', function($baseurl, $post){
  $uploads = wp_upload_dir();
  $baseurl = $uploads['baseurl'] . '/' . date('Y', strtotime($post->post_date) ) . '/' . date('m', strtotime($post->post_date) ) . '/pdf/';                
  return $baseurl;
}, 10, 2);

Changelog

1.2.3

  • Reducing calls to wp_uploads_dir for performance reasons

1.2.1
Reorganizing the path declarations and pdf existance check in save_post to improve performace.

1.2
Adding a parameter to save_pdf to not overwrite the PDF, if the PDF already exists. get_upload_basepath and get_upload_baseurl are now public, so other plugins can retrieve a PDF's location.

统计信息

  • 总下载量: 580
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 12
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2014-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固