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