PHP code example of voceconnect / voce-post-pdfs

1. Go to this page and download the library: Download voceconnect/voce-post-pdfs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voceconnect / voce-post-pdfs example snippets


if( ! class_exists( 'Voce_Post_PDFS' ) ) {
	

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

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

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

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

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';
});

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);

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);