PluginProbe
PDF Poster – let visitors read PDFs without leaving the page / 2.5.1
PDF Poster – let visitors read PDFs without leaving the page v2.5.1
2.5.6 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.1 1.2 1.3 1.4 1.5 1.6.3 1.6.5 2.0.11 2.0.6 2.0.8 2.1.12 2.1.18 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.2.0 2.2.1 All 33 releases
pdf-poster / pdf-poster.php

pdf-poster.php in PDF Poster – let visitors read PDFs without leaving the page 2.5.1, at pdf-poster.php

179 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * Plugin Name: PDF Poster
5 * Plugin URI: https://bplugins.com/products/pdf-poster/
6 * Description: You can easily embed/ show pdf file in your wordress website using this plugin.
7 * Version: 2.5.1
8 * Author: bPlugins
9 * Author URI: https://profiles.wordpress.org/abuhayat
10 * License: GPLv2
11 * Text Domain: pdfp
12 */
13 if ( !defined( 'ABSPATH' ) ) {
14 exit;
15 }
16 if ( function_exists( 'pdfp_fs' ) ) {
17 pdfp_fs()->set_basename( false, __FILE__ );
18 } else {
19 /*Some Set-up*/
20 define( 'PDFPRO_PLUGIN_DIR', plugin_dir_url( __FILE__ ) );
21 define( 'PDFPRO_PATH', plugin_dir_path( __FILE__ ) );
22 define( 'PDFPRO_VER', ( defined( 'WP_DEBUG' ) ? time() : '2.5.1' ) );
23 define( 'PDFPRO_IMPORT_VER', '1.0.0' );
24 if ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) {
25 require_once dirname( __FILE__ ) . '/vendor/autoload.php';
26 }
27 // DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK.
28 if ( !function_exists( 'pdfp_fs' ) ) {
29 // Create a helper function for easy SDK access.
30 function pdfp_fs() {
31 global $pdfp_fs;
32 if ( !isset( $pdfp_fs ) ) {
33 // Include Freemius SDK.
34 // SDK is auto-loaded through composer
35 $pdfp_fs = fs_dynamic_init( array(
36 'id' => '14261',
37 'slug' => 'pdf-poster',
38 'premium_slug' => 'pdf-poster-pro',
39 'type' => 'plugin',
40 'public_key' => 'pk_6e833032174d131283193892a44a2',
41 'is_premium' => false,
42 'premium_suffix' => 'Pro',
43 'has_addons' => false,
44 'has_paid_plans' => true,
45 'menu' => array(
46 'slug' => 'edit.php?post_type=pdfposter',
47 'first-path' => 'edit.php?post_type=pdfposter&page=pdf-poster#/welcome',
48 'support' => false,
49 'contact' => false,
50 ),
51 'is_live' => true,
52 'is_org_compliant' => true,
53 ) );
54 }
55 return $pdfp_fs;
56 }
57
58 // Init Freemius.
59 pdfp_fs();
60 // Signal that SDK was initiated.
61 do_action( 'pdfp_fs_loaded' );
62 }
63 if ( file_exists( __DIR__ . '/upgrade.php' ) ) {
64 require_once __DIR__ . '/upgrade.php';
65 }
66 if ( class_exists( 'PDFPro\\Init' ) ) {
67 PDFPro\Init::register_services();
68 }
69 function get_p_option( $array, $key = array(), $default = null ) {
70 if ( is_array( $array ) && array_key_exists( $key, $array ) ) {
71 return $array[$key];
72 }
73 return $default;
74 }
75
76 add_action( 'media_buttons', 'pdfp_my_media_button', 3 );
77 function pdfp_my_media_button() {
78 echo wp_kses_post( '<a href="#" id="insert-pdf" class="button pdfp_insert_pdf_btn">
79 <img src="' . PDFPRO_PLUGIN_DIR . '/img/icn.png' . '" alt="" width="20" height="20" style="position:relative; top:-1px">
80 Add PDF</a>' );
81 }
82
83 add_action( 'admin_init', 'pdfp_admin_init' );
84 function pdfp_admin_init() {
85 if ( get_option( 'pdfp_import', '0' ) != PDFPRO_IMPORT_VER ) {
86 PDFPro\Model\Import::meta();
87 PDFPro\Model\Import::settings();
88 update_option( 'pdfp_import', PDFPRO_IMPORT_VER );
89 }
90 }
91
92 add_action( 'wp_head', function () {
93 $option = get_option( 'fpdf_option' );
94 ?>
95 <style>
96 <?php
97 echo esc_html( $option['custom_css'] ?? '' );
98 ?>
99 </style>
100 <?php
101 } );
102 }
103 add_action( 'admin_footer', function () {
104 ?>
105 <script>
106 let tokenClient;
107 let accessToken = null;
108 let pickerInited = false;
109 let gisInited = false;
110
111 // Use the API Loader script to load google.picker.
112 function onApiLoad() {
113 gapi.load('picker', onPickerApiLoad);
114 }
115
116 function onPickerApiLoad() {
117 pickerInited = true;
118 createPicker();
119 }
120
121 function gisLoaded() {
122 // Replace with your client ID and required scopes.
123 tokenClient = google.accounts.oauth2.initTokenClient({
124 client_id: '637181304358-pj80esagrsfce2carm5638s7g6lkni3k.apps.googleusercontent.com',
125 scope: 'https://www.googleapis.com/auth/drive.readonly',
126 // callback: createPicker, // defined later
127 });
128 gisInited = true;
129 }
130
131 // Create and render a Google Picker object for selecting from Drive.
132 function createPicker() {
133 const showPicker = () => {
134 // Replace with your API key and App ID.
135 const picker = new google.picker.PickerBuilder()
136 .addView(google.picker.ViewId.DOCS)
137 .setOAuthToken(accessToken)
138 .setDeveloperKey('AIzaSyBlV3lAGilIjq0x2eJGodDs5DlkCigykZw')
139 .setCallback(pickerCallback)
140 .setAppId('637181304358')
141 .build();
142 picker.setVisible(true);
143 }
144
145 // Request an access token.
146 tokenClient.callback = async (response) => {
147 if (response.error !== undefined) {
148 throw (response);
149 }
150 accessToken = response.access_token;
151 showPicker();
152 };
153
154 if (accessToken === null) {
155 // Prompt the user to select a Google Account and ask for consent to share their data
156 // when establishing a new session.
157 tokenClient.requestAccessToken({ prompt: 'consent' });
158 } else {
159 // Skip display of account chooser and consent dialog for an existing session.
160 tokenClient.requestAccessToken({ prompt: '' });
161 }
162 }
163
164 // A callback implementation.
165 function pickerCallback(data) {
166 let url = 'nothing';
167 if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
168 const doc = data[google.picker.Response.DOCUMENTS][0];
169 url = doc[google.picker.Document.URL];
170 }
171 const message = `You picked: ${url}`;
172 document.getElementById('result').textContent = message;
173 }
174
175 </script>
176 <!-- <script async defer src="https://apis.google.com/js/api.js" onload="onApiLoad()"></script> -->
177 <!-- <script async defer src="https://accounts.google.com/gsi/client" onload="gisLoaded()"></script> -->
178 <?php
179 } );