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