first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,310 @@
<?php
namespace PDFP\Base;
class Activate{
protected $FILE = PDFP_FILE_;
protected $prefix = '';
protected $plugin_name = 'PDF Poster';
protected $url = 'https://bplugins.com/wp-json/data/v1/accept-data';
protected $status = false;
protected $post_type = 'pdfposter';
protected $version = PDFP_VER;
protected $nonce = null;
protected $marketing_allowed = false;
protected static $_instance = null;
protected $basename = null;
public function __construct(){
$this->register();
}
public static function instance(){
if(!self::$_instance){
self::$_instance = new self();
}
return self::$_instance;
}
public function register(){
$this->prefix = dirname(plugin_basename($this->FILE));
$this->status = get_option("$this->prefix-opt_in", false);
$this->last_check = get_option("$this->prefix-info-check", time()-1);
$this->marketing_allowed = get_option("$this->prefix-marketing-allowed", false);
$this->basename = plugin_basename($this->FILE);
register_activation_hook($this->FILE, [$this, 'activate']);
add_filter("plugin_action_links_$this->basename", [$this, 'opt_in_button'] );
add_action('admin_init', [$this, 'admin_init']);
if(!$this->status){
add_action('admin_menu', [$this, 'add_opt_in_menu']);
add_action('bts_opt_in', [$this, 'bts_opt_in']);
}
add_action('admin_enqueue_scripts', [$this, 'enqueue_assets']);
if($this->status == 'agreed'){
register_deactivation_hook( $this->FILE, [$this, 'deactivate'] );
}
add_action('admin_footer', [$this, 'opt_in_modal']);
}
public function opt_in_button($links){
if($this->marketing_allowed){
$settings_link = '<a href="'.admin_url("plugins.php?$this->prefix-allow=false").'" data-modal="'.$this->prefix.'">Opt out</a>';
}else {
$settings_link = '<a href="'.admin_url("plugins.php?$this->prefix-allow=true").'" class="bpc_opt_btn" data-modal="'.$this->prefix.'">Opt In</a>';
}
array_unshift($links, $settings_link);
return $links;
}
public function add_opt_in_menu(){
$this->nonce = \wp_create_nonce('bp_nonce');
add_submenu_page(
'',
$this->plugin_name,
$this->plugin_name,
'manage_options',
$this->prefix,
[$this, 'opt_in_form']
);
}
public function enqueue_assets($hook){
wp_register_script("$this->prefix-opt-in", plugin_dir_url($this->FILE).'dist/optin.js', [], $this->version);
wp_register_style("$this->prefix-opt-in", plugin_dir_url($this->FILE).'dist/optin.css', [], $this->version);
wp_localize_script("$this->prefix-opt-in", 'ppvOptData', [
'post_type' => $this->post_type,
'page' => admin_url("admin.php?page=$this->prefix"),
'basename' => $this->basename,
]);
if($hook === 'plugins.php' || $hook === "admin_page_$this->prefix"){
wp_enqueue_script("$this->prefix-opt-in");
wp_enqueue_style("$this->prefix-opt-in");
}
}
public function opt_in_form(){
update_option("$this->prefix-redirect", true);
global $wp_version;
wp_enqueue_script('bts-opt-in');
wp_enqueue_style('bts-opt-in');
$user = wp_get_current_user();
$skip_url = admin_url("edit.php?post_type=$this->post_type&bp_action={$this->prefix}_skipped_activate&nonce=$this->nonce");
$agree_url = admin_url("/admin.php?page=$this->prefix&opt_action=opt_accept&nonce=".wp_create_nonce('opt_action'));
?>
<div class="bts-opt-in">
<div class="content">
<div class="bp-connect">
<span class="wp-icon"><i class="dashicons dashicons-wordpress"></i></span>
<i class="dashicons dashicons-plus fs-second"></i>
<img src="<?php echo esc_url("https://ps.w.org/$this->prefix/assets/icon-128x128.png") ?>" alt="">
<i class="dashicons dashicons-plus fs-second"></i>
<img src="https://bplugins.com/wp-content/uploads/2021/07/bplugins-white.png" alt="">
</div>
<p>
Hey <b><?php echo esc_html($user->user_login) ?></b>,<br/> <?php echo esc_html__("Never miss an important update - opt in to our security and feature updates notifications, and non-sensitive diagnostic tracking with", "pdfp"); ?> bplugins.com.
</p>
</div>
<div class="actions">
<form method="POST" action="<?php echo $this->url ?>">
<input type="hidden" name="website" value="<?php echo esc_url(site_url()); ?>" />
<input type="hidden" name="user_email" value="<?php echo esc_attr($user->user_email); ?>" />
<input type="hidden" name="user_display_name" value="<?php echo esc_attr($user->display_name); ?>" />
<input type="hidden" name="user_nickname" value="<?php echo esc_attr($user->user_login); ?>" />
<input type="hidden" name="plugin_version" value="<?php echo esc_attr($this->version); ?>" />
<input type="hidden" name="php_version" value="<?php echo esc_attr(phpversion()); ?>" />
<input type="hidden" name="platform_version" value="<?php echo esc_attr($wp_version); ?>" />
<input type="hidden" name="status" value="activate" />
<input type="hidden" name="plugin_slug" value="<?php echo esc_attr($this->prefix) ?>" />
<input type="hidden" name="marketing_allowed" value="1" />
<input type="hidden" name="return_url" value="<?php echo esc_url(admin_url("edit.php?post_type=$this->post_type&bp_action={$this->prefix}_agreed_activate&nonce=$this->nonce")); ?>" />
<button class="button button-primary"><?php echo esc_html__("Agree & continue", "pdfp") ?></button>
</form>
<a href="<?php echo esc_url($skip_url) ?>" class="button button-secondary"><?php echo esc_html__("Skip", "pdfp"); ?></a>
</div>
<div class="what-is-granted">
<p class="details-btn"><?php echo esc_html__("What permissions are being granted?", "pdfp"); ?></p>
<div class="permissions">
<div class="permission">
<i class="dashicons dashicons-admin-users"></i>
<div>
<h3><?php echo esc_html__("YOUR PROFILE OVERVIEW", "pdfp"); ?></h3>
<p><?php echo esc_html__("Name and email address", "pdfp"); ?></p>
</div>
</div>
<div class="permission">
<i class="dashicons dashicons-admin-settings"></i>
<div>
<h3><?php echo esc_html__("YOUR SITE OVERVIEW", "pdfp"); ?></h3>
<p><?php echo esc_html__("Site URL, WP version, PHP info", "pdfp"); ?></p>
</div>
</div>
<div class="permission">
<i class="dashicons dashicons-testimonial"></i>
<div>
<h3><?php echo esc_html__("ADMIN NOTICES", "pdfp"); ?></h3>
<p><?php echo esc_html__("Updates, announcements, marketing, no spam", "pdfp"); ?></p>
</div>
</div>
<div class="permission">
<i class="dashicons dashicons-admin-plugins"></i>
<div>
<h3><?php echo esc_html__("CURRENT PLUGIN STATUS", "pdfp"); ?></h3>
<p><?php echo esc_html__("Active, deactivated, or uninstalled", "pdfp"); ?></p>
</div>
</div>
</div>
</div>
<div class="privacy-policy">
<a href="https://bplugins.com/privacy-policy/" target="_blank"><?php echo esc_html__("Privacy Policy", "pdfp"); ?></a>
<span>-</span>
<a href="https://bplugins.com/terms-of-service/" target="_blank"><?php echo esc_html__("Terms and Condition", "pdfp"); ?></a>
</div>
</div>
<style>
<?php echo esc_html("#menu-posts-$this->post_type") ?> ul{
display: none;
}
<?php echo esc_html("#menu-posts-$this->post_type") ?> > a{
background: #2271b1;
}
<?php echo esc_html("#menu-posts-$this->post_type") ?> div.wp-menu-image::before{
color: #fff;
}
</style>
<?php
// echo "<div id='bts-opt-in'></div>";
}
public function data_update($data = []){
global $wp_version;
$user = wp_get_current_user();
$response = wp_remote_post($this->url, array(
'method' => 'POST',
'timeout' => 45,
'headers' => array(),
'body' => wp_parse_args($data, [
'website' => site_url(),
'user_email' => $user->user_email,
'user_nickname' => $user->user_nickname ? $user->user_nickname : $user->user_login,
'php_version' => phpversion(),
'platform_version' => $wp_version,
'plugin_version' => $this->version
] )
)
);
}
public function admin_init(){
if(!$this->status){
if(isset($_GET['bp_action']) && isset($_GET['nonce'])){
$action = $_GET['bp_action'];
$nonce = $_GET['nonce'];
if(wp_verify_nonce($nonce, 'bp_nonce')){
if($action == "{$this->prefix}_skipped_activate"){
update_option("$this->prefix-opt_in", 'skipped');
}else if($action == "{$this->prefix}_agreed_activate") {
update_option("$this->prefix-opt_in", 'agreed');
update_option("$this->prefix-marketing-allowed", true);
}
}
}
$redirect = get_option("$this->prefix-redirect", false);
if(!$redirect){
wp_redirect("admin.php?page=$this->prefix");
}
}
if(isset($_GET["$this->prefix-allow"])){
if($_GET["$this->prefix-allow"] == "true"){
update_option("$this->prefix-marketing-allowed", true);
$this->data_update(['marketing_allowed' => true]);
}else {
update_option("$this->prefix-marketing-allowed", false);
$this->data_update(['marketing_allowed' => false]);
}
wp_redirect(admin_url('plugins.php'));
}
}
public function activate(){
if($this->status == 'agreed'){
$this->data_update(['status' => 'activate']);
}
}
public function deactivate(){
if($this->status == 'agreed'){
$this->data_update(['status' => 'deactivate']);
}
}
public function opt_in_modal($hook){
global $wp_version;
$user = \wp_get_current_user();
$screen = \get_current_screen();
if($screen->base === 'plugins'){
?>
<div id="opt_in_modal" class="opt_in_modal <?php echo esc_attr($this->prefix) ?>">
<div class="opt_in_content">
<div class="content">
<div>
<img src="<?php echo esc_url(plugin_dir_url( $this->FILE ).'img/shield_success.png') ?>" alt="">
</div>
<div>
<h3><?php echo esc_html__("Stay on the safe side", "pdfp") ?></h3>
<p><?php echo esc_html__("Receive our plugins alerts in case of critical security & feature updates and allow non-sensitive diagnostic tracking.", "pdfp") ?></p>
</div>
</div>
<div class="active-btn">
<form method="POST" action="<?php echo esc_url($this->url) ?>">
<input type="hidden" name="website" value="<?php echo esc_url(site_url()); ?>" />
<input type="hidden" name="user_email" value="<?php echo esc_attr($user->user_email); ?>" />
<input type="hidden" name="user_display_name" value="<?php echo esc_attr($user->display_name); ?>" />
<input type="hidden" name="user_nickname" value="<?php echo esc_attr($user->user_login); ?>" />
<input type="hidden" name="plugin_version" value="<?php echo esc_attr($this->version); ?>" />
<input type="hidden" name="php_version" value="<?php echo esc_attr(phpversion()); ?>" />
<input type="hidden" name="platform_version" value="<?php echo esc_attr($wp_version); ?>" />
<input type="hidden" name="status" value="activate" />
<input type="hidden" name="plugin_slug" value="<?php echo esc_attr($this->prefix) ?>" />
<input type="hidden" name="marketing_allowed" value="1" />
<input type="hidden" name="return_url" value="<?php echo esc_url(admin_url("plugins.php?$this->prefix-allow=true&bp_action={$this->prefix}_agreed_activate&nonce=$this->nonce")); ?>" />
<button class="button button-primary"><?php echo esc_html__("Agree & continue", "pdfp") ?></button>
</form>
</div>
<div class="granted-info">
<h3><?php echo esc_html__("You're granting these permissions", "pdfp") ?>:</h3>
<ul>
<li><?php echo esc_html__("Your profile information (name and email)", "pdfp") ?></li>
<li><?php echo esc_html__("Your site information (URL, WP version, PHP info)", "pdfp") ?></li>
<li><?php echo esc_html__("Plugin notices (updates, announcements, marketing, no spam)", "pdfp") ?></li>
<li><?php echo esc_html__("Plugin events (activation, deactivation and uninstall)", "pdfp") ?></li>
</ul>
</div>
<div class="learn-skip">
<a href="#" class="hide-btn"><?php echo esc_html__("hide", "pdfp") ?></a>
<a href="#" class="learn-more-btn"><?php echo esc_html__("Learn More", "pdfp") ?></a>|
<a href="#" class="skip-btn"><?php echo esc_html__("Skip", "pdfp") ?></a>
</div>
</div>
</div>
<?php
}
}
}
Activate::instance();

View File

@@ -0,0 +1,50 @@
<?php
namespace PDFP\Helper;
class DefaultArgs{
public static function parseArgs($data){
$default = self::get();
$data = wp_parse_args( $data, $default );
$data['options'] = wp_parse_args( $data['options'], $default['options'] );
$data['infos'] = wp_parse_args( $data['infos'], $default['infos'] );
$data['template'] = wp_parse_args( $data['template'], $default['template'] );
return $data;
}
public static function get(){
$options = [];
$infos = [
];
$template = array(
'file' => '',
'height' => '1122px',
'width' => '100%',
'classes' => '',
'showName' => false,
'print' => false,
'fullscreenButtonText' => 'View Fullscreen',
);
$default = [
'options' => $options,
'infos' => $infos,
'template' => $template
];
return $default;
}
// public static function brandColor(){
// $brandColor = get_option('h5vp_option', ['h5vp_player_primary_color' => '#1ABAFF' ]);
// if(isset($brandColor['h5vp_player_primary_color']) && !empty($brandColor['h5vp_player_primary_color'])){
// return $brandColor['h5vp_player_primary_color'];
// }else {
// return '#1ABAFF';
// }
// }
}

View File

@@ -0,0 +1,76 @@
<?php
namespace PDFP\Model;
use PDFP\Model\Block;
use PDFP\Helper\DefaultArgs;
use PDFP\Services\PDFTemplate;
class AdvanceSystem{
public static function html($id){
$blocks = Block::getBlock($id);
$output = '';
if(is_array($blocks)){
foreach($blocks as $block){
if(isset($block['attrs'])){
$output .= render_block($block);
}else {
$data = DefaultArgs::parseArgs(self::getData($block));
$output .= PDFTemplate::html($data);
}
}
}
return $output;
}
public static function getData($block){
$options = [];
$infos = [
];
$template = array(
'file' => self::i($block, 'file'),
'height' => self::i($block, 'height', '', '1122px'),
'width' => self::i($block, 'width', '', '100%'),
'classes' => '',
'showName' => self::i($block, 'showName', '', false),
'print' => self::i($block, 'print', '', false) == true ? 'true' : 'false',
'fullscreenButton' => self::i($block, 'fullscreenButton', '', true),
'fullscreenButtonText' => self::i($block, 'fullscreenButtonText', '', 'View Fullscreen')
);
$result = [
'options' => $options,
'infos' => $infos,
'template' => $template
];
return $result;
}
public static function i($array, $key1, $key2 = '', $default = false){
if(isset($array[$key1][$key2])){
return $array[$key1][$key2];
}else if (isset($array[$key1])){
return $array[$key1];
}
return $default;
}
public static function parseControls($controls){
$newControls = [];
if(!is_array($controls)){
return ['play','progress', 'current-time', 'mute', 'volume', 'settings', 'download'];
}
foreach($controls as $key => $value){
if($value == 1){
array_push($newControls, $key);
}
}
return $newControls;
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace PDFP\Model;
use PDFP\Helper\DefaultArgs;
use PDFP\Services\PDFTemplate;
class AnalogSystem{
public static function html($id){
$data = DefaultArgs::parseArgs(self::getData($id));
return PDFTemplate::html($data);
}
public static function parseArgs($data){
$default = DefaultArgs::get();
$data['options'] = wp_parse_args( $data['options'], $default['options'] );
$data['infos'] = wp_parse_args( $data['infos'], $default['infos'] );
$data['template'] = wp_parse_args( $data['template'], $default['template'] );
return wp_parse_args( $data, $default );
}
public static function getData($id){
$options = [];
$infos = [];
$height = self::GPM($id, 'height', ['height' => 1122, 'unit' => 'px']);
$width = self::GPM($id, 'width', ['width' => 100, 'unit' => '%']);
$template = array(
'file' => self::GPM($id, 'source', ''),
'height' => $height['height'].$height['unit'],
'width' => $width['width'].$width['unit'],
'classes' => '',
'showName' => self::GPM($id, 'show_filename', false, true),
'print' => self::GPM($id, 'print', false, 'false') == '1' ? 'true' : false,
'fullscreenButtonText' => self::GPM($id, 'fullscreen_btn_text', 'View Fullscreen')
);
return [
'options' => $options,
'infos' => $infos,
'template' => $template
];
}
public static function get_post_meta($id, $key, $default = false){
if (metadata_exists('post', $id, $key)) {
$value = get_post_meta($id, $key, true);
if ($value != '') {
return $value;
} else {
return $default;
}
} else {
return $default;
}
}
public static function GPM($id, $key, $default = false, $true = false){
$meta = metadata_exists( 'post', $id, '_fpdf' ) ? get_post_meta($id, '_fpdf', true) : '';
if(isset($meta[$key]) && $meta != ''){
if($true == true){
if($meta[$key] == '1'){
return true;
}else if($meta[$key] == '0'){
return false;
}
}else {
return $meta[$key];
}
}
return $default;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace PDFP\Model;
class Block{
public static function get($id){
$content_post = get_post($id);
$content = $content_post->post_content;
return $content;
}
public static function getBlock($id){
$blocks = parse_blocks(self::get($id));
$out = [];
foreach ($blocks as $block) {
if($block['blockName'] === 'pdfp/pdfposter'){
$out[] = $block['attrs'];
}else {
$out[] = $block;
}
}
return $out;
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace PDFP\Model;
class EnqueueAssets{
protected static $_instance = null;
public function __construct(){
add_action("wp_enqueue_scripts", [$this, 'publicAssets']);
add_action( 'admin_enqueue_scripts', [$this, 'adminAssets'] );
}
/**
* Create Instance
*/
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Enqueue public assets
*/
public function publicAssets(){
// wp_enqueue_script('jquery');
wp_register_style( 'pdfp-public', PDFP_PLUGIN_DIR. 'dist/public.css', array(), PDFP_PLUGIN_VERSION );
wp_register_script( 'pdfp-public', PDFP_PLUGIN_DIR. 'dist/public.js', array(), PDFP_PLUGIN_VERSION, true );
}
/**
* enqueue admin assets
**/
function adminAssets($hook) {
wp_enqueue_style('pdfp-admin', PDFP_PLUGIN_DIR.'dist/admin.css', array(), PDFP_PLUGIN_VERSION);
wp_enqueue_script('pdfp-admin', PDFP_PLUGIN_DIR.'dist/admin.js', array(), PDFP_PLUGIN_VERSION);
wp_enqueue_script( 'gum-js', PDFP_PLUGIN_DIR.'js/gumroad-embed.js', array(), PDFP_PLUGIN_VERSION );
}
}
EnqueueAssets::instance();

View File

@@ -0,0 +1,66 @@
<?php
namespace PDFP\Model;
class GlobalChanges{
protected static $_instance = null;
/**
* construct function
*/
public function __construct(){
add_action( 'admin_menu', [$this, 'pdfp_add_custom_link_into_cpt_menu'] );
add_action( 'admin_head', [$this, 'pdfp_my_custom_script'] );
add_filter( 'admin_footer_text', [$this, 'pdfp_admin_footer']);
if(is_admin()){
add_action('admin_footer', [$this, 'admin_footer']);
}
}
function admin_footer() {
$screen = get_current_screen();
if($screen->post_type === 'pdfposter' || $screen->base === 'plugins'){ ?>
<script type="text/javascript">
document.querySelector("ul#adminmenu a[href$='https://bplugins.com/products/pdf-poster/#pricing']")?.setAttribute('target', '_blank');
</script> <?php
}
}
/**
* Create instance function
*/
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
function pdfp_add_custom_link_into_cpt_menu() {
global $submenu;
$link = 'https://bplugins.com/products/pdf-poster/#pricing';
$submenu['edit.php?post_type=pdfposter'][] = array( 'Upgrade to PRO', 'manage_options', $link, 'meta'=>'target="_blank"' );
}
function pdfp_admin_footer( $text ) {
if ( 'pdfposter' == get_post_type() ) {
$url = 'https://wordpress.org/support/plugin/pdf-poster/reviews/?filter=5#new-post';
$text = sprintf( __( 'If you like <strong>Pdf Poster</strong> please leave us a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating. Your Review is very important to us as it helps us to grow more. ', 'h5vp-domain' ), $url );
}
return $text;
}
function pdfp_my_custom_script() {
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$( "ul#adminmenu a[href$='http://pdfposter.com']" ).attr( 'target', '_blank' );
});
</script>
<?php
}
}
GlobalChanges::instance();

View File

@@ -0,0 +1,73 @@
<?php
namespace PDFP\Model;
class Import{
public static function meta(){
$query = new \WP_Query(array(
'post_type' => 'pdfposter',
'post_status' => 'any',
'posts_per_page' => -1
));
$output = [];
while($query->have_posts()): $query->the_post();
$id = \get_the_ID();
$meta = [
'source' => get_post_meta($id, 'meta-image', true),
'height' => [
'height' => get_post_meta($id, 'pdfp_onei_pp_height', true) == '' ? 840 : get_post_meta($id, 'pdfp_onei_pp_height', true),
'unit' => 'px'
],
'width' => [
'width' => get_post_meta($id, 'pdfp_onei_pp_width', true) == '' ? 100 : get_post_meta($id, 'pdfp_onei_pp_width', true),
'unit' => get_post_meta($id, 'pdfp_onei_pp_width', true) == '' ? '%' : 'px',
],
'print' => get_post_meta($id, 'pdfp_onei_pp_print', true) == 'on' ? true : false,
'showName' => get_post_meta($id, 'pdfp_onei_pp_pgname', true) == 'on' ? true : false
];
if (\metadata_exists('post', $id, '_fpdf') == false) {
\update_post_meta($id, '_fpdf', $meta);
}
endwhile;
}
public static function importMeta(){
$pdfs = self::createBlock();
foreach($pdfs as $pdf){
$content_post = get_post($pdf['ID']);
$content = $content_post->post_content;
if($content == ''){
wp_update_post($pdf);
}
}
}
public static function createBlock(){
$query = new \WP_Query(array(
'post_type' => 'pdfposter',
'post_status' => 'any',
'posts_per_page' => -1
));
$output = [];
while($query->have_posts()): $query->the_post();
$id = \get_the_ID();
$output[] = [
'ID' => $id,
'post_content' => '<!-- wp:pdfp/pdfposter '.json_encode([
'file' => get_post_meta($id, 'meta-image', true),
'title' => basename(get_post_meta($id, 'meta-image', true)),
'height' => get_post_meta($id, 'pdfp_onei_pp_height', true) == '' ? '1122px' : get_post_meta($id, 'pdfp_onei_pp_height', true).'px',
'width' => get_post_meta($id, 'pdfp_onei_pp_width', true) == '' ? '100%' : get_post_meta($id, 'pdfp_onei_pp_width', true).'px',
'print' => get_post_meta($id, 'pdfp_onei_pp_print', true) == 'on' ? true : false,
'showName' => get_post_meta($id, 'pdfp_onei_pp_pgname', true) == 'on' ? true : false
]).' /-->'
];
endwhile;
return $output;
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace PDFP\Model;
class Metabox{
protected static $_instance = null;
/**
* construct function
*/
public function __construct(){
if(is_admin()){
add_action( 'add_meta_boxes', [$this, 'myplugin_add_meta_box'] );
add_action( 'wp_dashboard_setup', [$this, 'pdfp_add_dashboard_widgets'] );
}
}
/**
* Create instance function
*/
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
/**
* register metabox
*/
function myplugin_add_meta_box() {
add_meta_box(
'donation',
__( 'Support PDF Poster', 'myplugin_textdomain' ),
[$this, 'pdfp_callback_donation'],
'pdfposter'
);
add_meta_box(
'myplugin_sectionid',
__( 'Pdf Poster LightBox Addons', 'myplugin_textdomain' ),
[$this, 'pdfp_addons_callback'],
'pdfposter',
'side'
);
add_meta_box(
'myplugin',
__( 'Please show some love', 'myplugin_textdomain' ),
[$this, 'pdfp_callback'],
'pdfposter',
'side'
);
}
public function pdfp_callback_donation( ) {
echo '<p>It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using the plugin and find it useful, please consider support by <b>DONATION</b> or <b>BUY THE PRO VERSION (Ad Less)</b> of the Plugin. Your support will help encourage and support the plugins continued development and better user support.</p>
<center>
<a target="_blank" href="https://gum.co/wpdonate"><div><img width="200" src="'.PDFP_PLUGIN_DIR.'img/donation.png'.'" alt="Donate Now" /></div></a>
</center>
<br />
<div class="gumroad-product-embed" data-gumroad-product-id="zUvK" data-outbound-embed="true"><a href="https://gumroad.com/l/zUvK">Loading...</a></div>';
}
public function pdfp_addons_callback(){
echo'<a target="_blank" href="https://bplugins.gumroad.com/l/pdfaddons"><img style="width:100%" src="'.PDFP_PLUGIN_DIR.'/img/upwork.png" ></a>
<p>LightBox Addons enable Pdf poster to open a pdf file in a lightBox. </p>
<table>
<tr>
<td><a class="button button-primary button-large" href="https://pdfposter.com/lightbox-addons/" target="_blank">See Demo </a></td>
<td><a class="button button-primary button-large" href="https://bplugins.gumroad.com/l/pdfaddons" target="_blank">Buy Now</a></td>
</tr>
</table>';
}
public function pdfp_callback( ) {
echo'
<ul style="list-style-type: square;padding-left:10px;">
<li><a href="https://wordpress.org/support/plugin/pdf-poster/reviews/?filter=5#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733; Rate </a> <strong>Pdf Poster</strong> Plugin</li>
<li>Take a screenshot along with your name and the comment. </li>
<li><a href="mailto:pluginsfeedback@gmail.com">Email us</a> ( pluginsfeedback@gmail.com ) the screenshot.</li>
<li>You will receive a promo Code of 100% Off.</li>
</ul>
Your Review is very important to us as it helps us to grow more.</p>
<p>Not happy, Sorry for that. You can request for improvement. </p>
<table>
<tr>
<td><a class="button button-primary button-large" href="https://wordpress.org/support/plugin/pdf-poster/reviews/?filter=5#new-post" target="_blank">Write Review</a></td>
<td><a class="button button-primary button-large" href="mailto:abuhayat.du@gmail.com" target="_blank">Request Improvement</a></td>
</tr>
</table>';
}
public function pdfp_add_dashboard_widgets() {
wp_add_dashboard_widget( 'pdfp_example_dashboard_widget', 'Support PDF Poster', [$this, 'pdfp_dashboard_widget_function'] );
global $wp_meta_boxes;
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$example_widget_backup = array( 'pdfp_example_dashboard_widget' => $normal_dashboard['pdfp_example_dashboard_widget'] );
unset( $normal_dashboard['pdfp_example_dashboard_widget'] );
$sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard );
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
}
public function pdfp_dashboard_widget_function() {
// Display whatever it is you want to show.
echo '<p>It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using the plugin and find it useful, please consider support by <b>DONATION</b> or <b>BUY THE PRO VERSION (Ad Less)</b> of the Plugin. Your support will help encourage and support the plugins continued development and better user support.</p>
<center>
<a target="_blank" href="https://gum.co/wpdonate"><div><img width="200" src="'.PDFP_PLUGIN_DIR.'img/donation.png'.'" alt="Donate Now" /></div></a>
</center> <br />
<div class="gumroad-product-embed" data-gumroad-product-id="zUvK" data-outbound-embed="true"><a href="https://gumroad.com/l/zUvK">Loading...</a></div>';
}
}
Metabox::instance();

View File

@@ -0,0 +1,211 @@
<?php
namespace PDP\PostType;
class Podcast{
protected static $_instance = null;
protected $post_type = 'pdfposter';
/**
* construct function
*/
public function __construct(){
add_action('init', [$this, 'init']);
if ( is_admin() ) {
add_filter( 'post_row_actions', [$this, 'pdfp_remove_row_actions'], 10, 2 );
add_action('edit_form_after_title', [$this, 'pdfp_shortcode_area']);
add_filter('manage_pdfposter_posts_columns', [$this, 'pdfp_columns_head_only_podcast'], 10);
add_action('manage_pdfposter_posts_custom_column', [$this, 'pdfp_columns_content_only_podcast'], 10, 2);
add_filter('post_updated_messages', [$this, 'pdfp_updated_messages']);
add_action('admin_head-post.php', [$this, 'pdfp_hide_publishing_actions']);
add_action('admin_head-post-new.php', [$this, 'pdfp_hide_publishing_actions']);
add_filter( 'gettext', [$this, 'pdfp_change_publish_button'], 10, 2 );
add_filter( 'filter_block_editor_meta_boxes', [$this, 'remove_metabox'] );
add_action('use_block_editor_for_post', [$this, 'forceGutenberg'], 10, 2);
}
}
/**
* Create instance function
*/
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
/**
* init
*/
public function init(){
register_post_type( 'pdfposter',
array(
'labels' => array(
'name' => __( 'PDF Poster'),
'singular_name' => __( 'Pdf Poster' ),
'add_new' => __( 'Add New Pdf' ),
'add_new_item' => __( 'Add New Pdf' ),
'edit_item' => __( 'Edit' ),
'new_item' => __( 'New Pdf' ),
'view_item' => __( 'View Pdf' ),
'search_items' => __( 'Search Pdf'),
'not_found' => __( 'Sorry, we couldn\'t find the Pdf file you are looking for.' )
),
'public' => false,
'show_ui' => true,
// 'publicly_queryable' => true,
// 'exclude_from_search' => true,
'show_in_rest' => true,
'menu_position' => 14,
'menu_icon' =>PDFP_PLUGIN_DIR .'/img/icn.png',
'has_archive' => false,
'hierarchical' => false,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'pdfposter' ),
'supports' => array( 'title', 'editor' ),
'template' => [
['pdfp/pdfposter']
],
'template_lock' => 'all'
)
);
// // 'publicly_queryable' => true,
// // 'exclude_from_search' => true,
// 'show_in_rest' => true,
// 'supports' => array('title', 'editor'),
// 'template' => [
// ['pdp/podcast']
// ],
// 'template_lock' => 'all',
}
/**
* Remove Row
*/
function pdfp_remove_row_actions( $idtions ) {
global $post;
if( $post->post_type == $this->post_type ) {
unset( $idtions['view'] );
unset( $idtions['inline hide-if-no-js'] );
}
return $idtions;
}
function pdfp_shortcode_area(){
global $post;
if($post->post_type== $this->post_type){
?>
<div class="pdfp_playlist_shortcode">
<div class="shortcode-heading">
<div class="icon"><span class="dashicons dashicons-pdf"></span> <?php _e("WP Podcast", "pdfp") ?></div>
<div class="text"> <a href="https://bplugins.com/support/" target="_blank"><?php _e("Supports", "pdfp") ?></a></div>
</div>
<div class="shortcode-left">
<h3><?php _e("Shortcode", "pdfp") ?></h3>
<p><?php _e("Copy and paste this shortcode into your posts, pages and widget:", "pdfp") ?></p>
<div class="shortcode" selectable>[pdf id='<?php echo esc_attr($post->ID); ?>']</div>
</div>
<div class="shortcode-right">
<h3><?php _e("Template Include", "pdfp") ?></h3>
<p><?php _e("Copy and paste the PHP code into your template file:", "pdfp"); ?></p>
<div class="shortcode">&lt;?php echo do_shortcode('[pdf id="<?php echo esc_html($post->ID); ?>"]');
?&gt;</div>
</div>
</div>
<h2 style="margin: 10px 0 0; font-size: 20px;"><?php esc_html_e('You can enable Gutenberg shortcode generator from PDF Poster -> Settings', 'pdfp') ?></h2>
<?php
}
}
// CREATE TWO FUNCTIONS TO HANDLE THE COLUMN
function pdfp_columns_head_only_podcast($defaults) {
unset($defaults['date']);
$defaults['shortcode'] = 'ShortCode';
$defaults['date'] = 'Date';
return $defaults;
}
function pdfp_columns_content_only_podcast($column_name, $post_ID) {
if ($column_name == 'shortcode') {
echo '<div class="pdfp_front_shortcode"><input style="text-align: center; border: none; outline: none; background-color: #1e8cbe; color: #fff; padding: 4px 10px; border-radius: 3px;" value="[pdf id='. esc_attr($post_ID) . ']" ><span class="htooltip">Copy To Clipboard</span></div>';
}
}
function pdfp_updated_messages( $messages ) {
$messages[$this->post_type][1] = __('updated ');
return $messages;
}
public function pdfp_hide_publishing_actions(){
global $post;
if($post->post_type == $this->post_type){
echo '
<style type="text/css">
#misc-publishing-actions,
#minor-publishing-actions{
display:none;
}
</style>
';
}
}
function remove_metabox($metaboxs) {
global $post;
$screen = get_current_screen();
if($screen->post_type === $this->post_type){
return false;
}
return $metaboxs;
}
public function forceGutenberg($use, $post)
{
$gutenberg = (boolean) get_option('pdfp_gutenberg_enable', false);
$isGutenberg = (boolean) get_post_meta($post->ID, 'isGutenberg', true);
$pluginUpdated = 1630223686;
$publishDate = get_the_date('U', $post);
$currentTime = current_time("U");
if ($this->post_type === $post->post_type) {
if($gutenberg){
if($post->post_status == 'auto-draft' ){
update_post_meta($post->ID, 'isGutenberg', true);
return true;
}else {
if($isGutenberg){
return true;
}else {
remove_post_type_support($this->post_type, 'editor');
return false;
}
}
}else {
if($isGutenberg){
return true;
}else {
remove_post_type_support($this->post_type, 'editor');
return false;
}
}
}
return $use;
}
function pdfp_change_publish_button( $translation, $text ) {
if ( $this->post_type == get_post_type())
if ( $text == 'Publish' )
return 'Save';
return $translation;
}
}
Podcast::instance();

View File

@@ -0,0 +1,65 @@
<?php
use PDFP\Model\Block;
use PDFP\Model\AdvanceSystem;
if(!class_exists('GET_PPV_META')){
class GET_PPV_META{
function __construct(){
$this->route = '/single(?:/(?P<id>\d+))?';
add_action('rest_api_init', [$this, 'single_doc']);
}
public function single_doc(){
register_rest_route( 'pdfposter/v1',
$this->route,
[
'methods' => 'GET',
'callback' => [$this, 'single_doc_callback'],
'permission_callback' => '__return_true',
]
);
}
function single_doc_callback(WP_REST_Request $request){
$response = [];
$params = $request->get_params();
$id = $params['id'];
$data = $this->get_data($id);
// $video = ['data' => 'no data available'];
return new WP_REST_Response($data);
}
public function get_data( $id = 2038){
$blocks = Block::getBlock($id);
if(isset($blocks[0])){
$data = AdvanceSystem::getData($blocks[0]);
if(isset($data['template'])){
return $data['template'];
}
}
return false;
return $result;
}
public static function meta($id, $key, $default = null){
if (metadata_exists('post', $id, $key)) {
$value = get_post_meta($id, $key, true);
if ($value != '') {
return $value;
} else {
return $default;
}
} else {
return $default;
}
}
}
new GET_PPV_META();
}

View File

@@ -0,0 +1,93 @@
<?php
namespace PDPF\Services;
class Menu {
protected static $_instance = null;
/**
* construct function
*/
public function __construct(){
add_action( 'init', [$this, 'registerSettings'] );
add_action( 'admin_menu', [$this, 'registerMenu'] );
add_action( 'admin_footer', [$this, 'admin_footer'] );
}
/**
* Create instance function
*/
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Register Settings
*/
function registerSettings() {
register_setting(
'pdfp_settings',
'pdfp_gutenberg_enable',
array(
'type' => 'boolean',
'show_in_rest' => true,
'default' => false,
)
);
register_setting(
'pdfp_settings',
'bpm_gutenberg_enable',
array(
'type' => 'boolean',
'show_in_rest' => true,
'default' => false,
)
);
}
/**
* Register Menu
*/
function registerMenu() {
$page_hook_suffix = add_submenu_page(
'edit.php?post_type=pdfposter',
__( 'Settings', 'pdfp' ),
__( 'Settings', 'pdfp' ),
'manage_options',
'settings',
[$this, 'settings_callback']
);
add_action( "admin_print_scripts-{$page_hook_suffix}", [$this, 'eqnueueAssets'] );
global $submenu;
$link = 'https://bplugins.com/products/pdf-poster/#pricing';
$submenu['edit.php?post_type=pdfposter'][] = array( 'Upgrade to PRO', 'manage_options', $link);
}
/**
* Settings Page Callback
*/
function settings_callback() {
echo '<div id="pdfp-settings"></div>';
}
function eqnueueAssets() {
wp_enqueue_script( 'pdfp-settings', PDFP_PLUGIN_DIR . 'dist/settings.js', array( 'wp-api', 'wp-i18n', 'wp-components', 'wp-element' ), PDFP_VER, true );
wp_enqueue_style( 'pdfp-settings', PDFP_PLUGIN_DIR . 'dist/settings.css', array( 'wp-components' ) );
}
function admin_footer() {
$screen = get_current_screen();
if($screen->post_type === 'pdfposter' || $screen->base === 'plugins'){ ?>
<script type="text/javascript">
document.querySelector("ul#adminmenu a[href$='https://bplugins.com/products/pdf-poster/#pricing']")?.setAttribute('target', '_blank');
</script> <?php
}
}
}
Menu::instance();

View File

@@ -0,0 +1,128 @@
<?php
namespace PDFP\Services;
use PDFP\Helper\DefaultArgs;
// use PDFP\Helper\Functions;
use PDFP\Services\AnalogSystem;
class PDFTemplate{
public static $uniqid = null;
protected static $styles = [];
protected static $mediaQuery = [];
public static function html($data){
self::createId();
self::enqueueEssentialAssets();
$iid = self::$uniqid;
$t = $data['template'];
ob_start();
?>
<style>
<?php echo esc_html(self::renderStyle($data['template'])); ?>
</style>
<?php if($t['file']){ ?>
<div id="<?php echo esc_attr($iid); ?>" class="pdfp_wrapper">
<?php
$viewer_base_url= plugins_url()."/pdf-poster/pdfjs/web/viewer.html";
$final_url = $viewer_base_url."?file=".$t['file']."&download=true&print=".$t['print']."&openfile=false";
?>
<div class="cta_wrapper">
<?php if($t['showName']): ?>
<p>File name : <?php echo esc_html(basename($t['file']));?></p>
<?php endif;?>
<p><a class="fullscreenBtn" href="<?php echo esc_url($final_url); ?>"><button><?php echo esc_html($t['fullscreenButtonText']) ?></button></a></p>
</div>
<div class="iframe_wrapper">
<span class="close">&times;</span>
<iframe loading="lazy" width="<?php echo esc_attr($t['width']) ;?>" height="<?php echo esc_attr($t['height']) ;?>" src="<?php echo esc_url($final_url);?>"></iframe>
</div>
</div>
<?php } else {
echo "<h3>Oops! You forgot to select a pdf file. </h3>";
}
return ob_get_clean();
}
public static function enqueueEssentialAssets(){
wp_enqueue_style( 'pdfp-public');
wp_enqueue_script( 'pdfp-public');
}
public static function renderStyle($template){
$id = self::$uniqid;
self::addStyle("#$id .iframe_wrapper", ['width' => $template['width']]);
self::addStyle("#$id .iframe_wrapper", ['height' => $template['height']]);
$output = '';
foreach(self::$styles as $selector => $style){
$new = '';
foreach($style as $property => $value){
if($value == ''){
$new .= $property;
}else {
$new .= " $property: $value;";
}
}
$output .= "$selector { $new }";
}
foreach(self::$mediaQuery as $query => $styles){
$output .= $query."{";
foreach($styles as $selector => $style){
$new = '';
foreach($style as $property => $value){
if($value == ''){
$new .= $property;
}else {
$new .= " $property: $value;";
}
}
$output .= "$selector { $new }";
}
$output .= "}";
}
return $output;
}
public static function addStyle($selector, $styles, $mediaQuery = false){
if($mediaQuery){
if(array_key_exists($mediaQuery, self::$mediaQuery)){
if(array_key_exists($selector, self::$mediaQuery[$mediaQuery])){
self::$mediaQuery[$mediaQuery][$selector] = wp_parse_args(self::$mediaQuery[$mediaQuery][$selector], $styles);
}else {
self::$mediaQuery[$mediaQuery] = wp_parse_args(self::$mediaQuery[$mediaQuery], [$selector => $styles]);
}
}else {
self::$mediaQuery[$mediaQuery] = [$selector => $styles];
}
}else {
if(array_key_exists($selector, self::$styles)){
self::$styles[$selector] = wp_parse_args(self::$styles[$selector], $styles);
}else {
self::$styles[$selector] = $styles;
}
}
}
public static function createId(){
self::$uniqid = "h5vp".uniqid();
}
public static function splice($string){
if(strlen($string) < 45){
return $string;
}
return substr($string, 0, 40)."...";
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace PDFP\Services;
use PDFP\Model\AdvanceSystem;
use PDFP\Model\AnalogSystem;
class Shortcodes{
protected static $_instance = null;
public function __construct(){
add_shortcode('pdf', [$this, 'pdf'], 10, 2);
}
public static function instance(){
if(self::$_instance === null){
self::$_instance = new self();
}
return self::$_instance;
}
public function pdf($atts, $content){
extract(shortcode_atts(array(
'id' => null,
), $atts));
$post_type = get_post_type($id);
$pluginUpdated = 1630223686;
$publishDate = get_the_date('U', $id);
$isGutenberg = get_post_meta($id, 'isGutenberg', true);
$post = get_post($id);
ob_start();
if($post_type !== 'pdfposter'){
return false;
}
if($pluginUpdated < $publishDate && $post->post_content != '' || $isGutenberg){
echo( AdvanceSystem::html($id));
}else {
echo Analogsystem::html($id);
}
return ob_get_clean();
}
}
Shortcodes::instance();