<?php
/**
* Plugin Name: Panorama
* Description: A lite Weight Plugin that helps you, Easily display panoramic 360 degree images / videos into WordPress Website in Post, Page, Widget Area using shortCode.
* Plugin URI: https://wordpress.org/plugins/
* Version: 1.0.8
* Author: bPlugins LLC
* Author URI: http://abuhayatpolash.com
* License: GPLv3
* Text Domain: panorama-viewer
* Domain Path: /languages
*/
// Security check
if ( !defined( 'ABSPATH' ) ) {
exit;
}
if ( function_exists( 'panorama_fs' ) ) {
panorama_fs()->set_basename( false, __FILE__ );
} else {
// DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK.
if ( !function_exists( 'panorama_fs' ) ) {
// ... Freemius integration snippet ...
function panorama_fs()
{
global $panorama_fs ;
if ( !isset( $panorama_fs ) ) {
// Include Freemius SDK.
require_once dirname( __FILE__ ) . '/freemius/start.php';
$panorama_fs = fs_dynamic_init( array(
'id' => '8824',
'slug' => 'panorama',
'type' => 'plugin',
'public_key' => 'pk_a112d1d1d66d3b480dbea5690d3ff',
'is_premium' => false,
'premium_suffix' => 'Pro',
'has_addons' => false,
'has_paid_plans' => true,
'trial' => array(
'days' => 7,
'is_require_payment' => false,
),
'menu' => array(
'slug' => 'edit.php?post_type=bppiv-image-viewer',
),
'is_live' => true,
) );
}
return $panorama_fs;
}
// Init Freemius.
panorama_fs();
// Signal that SDK was initiated.
do_action( 'panorama_fs_loaded' );
}
// ... Your plugin's main file logic ...
/* Plugin Initialization */
define( 'BPPIV_PLUGIN_DIR', plugin_dir_url( __FILE__ ) );
define( 'BPPIV_VERSION', '1.0.8' );
add_action( 'plugin_loaded', 'bppiv_textdomain' );
function bppiv_textdomain()
{
load_textdomain( 'panorama-viewer', BPPIV_PLUGIN_DIR . 'languages' );
}
// Register Scripts and style
function bppiv_assets()
{
// scripts
wp_register_script(
'bppiv-three',
BPPIV_PLUGIN_DIR . 'public/assets/js/three.min.js',
array(),
BPPIV_VERSION,
true
);
wp_register_script(
'bppiv-panolens',
BPPIV_PLUGIN_DIR . 'public/assets/js/panolens.min.js',
array( 'bppiv-three' ),
BPPIV_VERSION,
true
);
//Pannellum
wp_register_script(
'bppiv-pannellum-js',
BPPIV_PLUGIN_DIR . 'public/assets/js/pannellum.min.js',
array(),
BPPIV_VERSION,
true
);
wp_register_script(
'bppiv-init',
BPPIV_PLUGIN_DIR . 'public/assets/js/scripts.js',
array( 'jquery', 'bppiv-three', 'bppiv-panolens' ),
BPPIV_VERSION,
true
);
wp_register_script(
'bppiv-pro',
BPPIV_PLUGIN_DIR . 'public/assets/js/scripts-pro.js',
array(
'jquery',
'bppiv-three',
'bppiv-panolens',
'bppiv-pannellum-js'
),
BPPIV_VERSION,
true
);
//Pannellum CSS
wp_register_style(
'bppiv-pannellum-css',
BPPIV_PLUGIN_DIR . 'public/assets/css/pannellum.min.css',
array(),
'2.5.6'
);
// style
wp_register_style( 'bppiv-font-material', '//fonts.googleapis.com/icon?family=Material+Icons' );
wp_register_style(
'bppiv-main-style',
BPPIV_PLUGIN_DIR . 'public/assets/css/style.css',
array(),
BPPIV_VERSION
);
wp_enqueue_style( 'bppiv-font-material' );
wp_enqueue_style( 'bppiv-pannellum-css' );
wp_enqueue_style( 'bppiv-main-style' );
}
add_action( 'wp_enqueue_scripts', 'bppiv_assets' );
// Additional admin style
function bppiv_admin_style()
{
wp_register_style(
'bppiv-custom-style',
BPPIV_PLUGIN_DIR . 'public/assets/css/admin-style.css',
array(),
BPPIV_VERSION
);
wp_enqueue_style( 'bppiv-custom-style' );
// Script
wp_register_script(
'bppiv-admin-script',
BPPIV_PLUGIN_DIR . 'public/assets/js/admin-scripts.js',
array( 'jquery' ),
BPPIV_VERSION,
true
);
wp_enqueue_script( 'bppiv-admin-script' );
}
add_action( 'admin_enqueue_scripts', 'bppiv_admin_style' );
// Custom post-type for bppiv
function bppiv_viewer()
{
$labels = array(
'name' => __( 'Panorama Viewer', 'panorama-viewer' ),
'menu_name' => __( 'Panorama Viewer', 'panorama-viewer' ),
'name_admin_bar' => __( 'Panorama Viewer', 'panorama-viewer' ),
'add_new' => __( 'Add New', 'panorama-viewer' ),
'add_new_item' => __( 'Add New ', 'panorama-viewer' ),
'new_item' => __( 'New Panorama ', 'panorama-viewer' ),
'edit_item' => __( 'Edit Panorama ', 'panorama-viewer' ),
'view_item' => __( 'View Panorama ', 'panorama-viewer' ),
'all_items' => __( 'All Panoramas', 'panorama-viewer' ),
'not_found' => __( 'Sorry, we couldn\'t find the Feed you are looking for.' ),
);
$args = array(
'labels' => $labels,
'description' => __( 'Panorama Options.', 'panorama-viewer' ),
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-welcome-view-site',
'query_var' => true,
'rewrite' => array(
'slug' => 'panorama-viewer',
),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 20,
'supports' => array( 'title' ),
);
register_post_type( 'bppiv-image-viewer', $args );
}
add_action( 'init', 'bppiv_viewer' );
/*-------------------------------------------------------------------------------*/
/* Additional Features
/*-------------------------------------------------------------------------------*/
// Hide & Disabled View, Quick Edit and Preview Button
function bppiv_remove_row_actions( $idtions )
{
global $post ;
if ( $post->post_type == 'bppiv-image-viewer' ) {
unset( $idtions['view'] );
unset( $idtions['inline hide-if-no-js'] );
}
return $idtions;
}
if ( is_admin() ) {
add_filter(
'post_row_actions',
'bppiv_remove_row_actions',
10,
2
);
}
// HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
function bppiv_hide_publishing_actions()
{
$my_post_type = 'bppiv-image-viewer';
global $post ;
if ( $post->post_type == $my_post_type ) {
echo '
<style type="text/css">
#misc-publishing-actions,
#minor-publishing-actions{
display:none;
}
</style>
' ;
}
}
add_action( 'admin_head-post.php', 'bppiv_hide_publishing_actions' );
add_action( 'admin_head-post-new.php', 'bppiv_hide_publishing_actions' );
/*-------------------------------------------------------------------------------*/
// Remove post update massage and link
/*-------------------------------------------------------------------------------*/
function bppiv_updated_messages( $messages )
{
$messages['bppiv-image-viewer'][1] = __( 'Shortcode updated ', 'panorama-viewer' );
return $messages;
}
add_filter( 'post_updated_messages', 'bppiv_updated_messages' );
/*-------------------------------------------------------------------------------*/
/* Change publish button to save.
/*-------------------------------------------------------------------------------*/
add_filter(
'gettext',
'bppiv_change_publish_button',
10,
2
);
function bppiv_change_publish_button( $translation, $text )
{
if ( 'bppiv-image-viewer' == get_post_type() ) {
if ( $text == 'Publish' ) {
return 'Save';
}
}
return $translation;
}
/*-------------------------------------------------------------------------------*/
/* Footer Review Request .
/*-------------------------------------------------------------------------------*/
add_filter( 'admin_footer_text', 'bppiv_admin_footer' );
function bppiv_admin_footer( $text )
{
if ( 'bppiv-image-viewer' == get_post_type() ) {
$url = 'https://wordpress.org/support/plugin/panorama/reviews/?filter=5#new-post';
$text = sprintf( __( 'If you like <strong> Panorama Viewer </strong> please leave us a <a href="%s" target="_blank">★★★★★</a> rating. Your Review is very important to us as it helps us to grow more. ', 'panorama-viewer' ), $url );
}
return $text;
}
/*-------------------------------------------------------------------------------*/
/* ONLY CUSTOM POST TYPE POSTS .
/*-------------------------------------------------------------------------------*/
add_filter( 'manage_bppiv-image-viewer_posts_columns', 'bppiv_columns_head_only_panorama', 10 );
add_action(
'manage_bppiv-image-viewer_posts_custom_column',
'bppiv_columns_content_only_panorama',
10,
2
);
// CREATE TWO FUNCTIONS TO HANDLE THE COLUMN
function bppiv_columns_head_only_panorama( $defaults )
{
$defaults['directors_name'] = 'ShortCode';
return $defaults;
}
function bppiv_columns_content_only_panorama( $column_name, $post_ID )
{
if ( $column_name == 'directors_name' ) {
// show content of 'directors_name' column
echo '<input onClick="this.select();" value="[panorama id=' . $post_ID . ']" >' ;
}
}
/*-------------------------------------------------------------------------------*/
/* Shortcode Generator area .
/*-------------------------------------------------------------------------------*/
add_action( 'edit_form_after_title', 'bppiv_shortcode_area' );
function bppiv_shortcode_area()
{
global $post ;
if ( $post->post_type == 'bppiv-image-viewer' ) {
?>
<div class="shortcode_gen">
<label for="bppiv_shortcode"><?php
esc_html_e( 'Copy this shortcode and paste it into your post, page, or text widget content', 'panorama-viewer' );
?>:</label>
<span>
<input type="text" id="bppiv_shortcode" onfocus="this.select();" readonly="readonly" value="[panorama id=<?php
echo $post->ID ;
?>]" />
</span>
</div>
<?php
}
}
// After activation redirect
function bppiv_plugin_activate()
{
add_option( 'bppiv_plugin_do_activation_redirect', true );
}
register_activation_hook( __FILE__, 'bppiv_plugin_activate' );
function bppiv_plugin_redirect()
{
if ( get_option( 'bppiv_plugin_do_activation_redirect', false ) ) {
delete_option( 'bppiv_plugin_do_activation_redirect' );
}
}
add_action( 'admin_init', 'bppiv_plugin_redirect' );
/*-------------------------------------------------------------------------------*/
/* FRAMEWORK + OTHER INC
/*-------------------------------------------------------------------------------*/
require_once 'inc/csf/csf-config.php';
require_once 'admin/ads/submenu.php';
//free version code
if ( panorama_fs()->is_free_plan() ) {
require_once 'inc/metabox-options-free.php';
require_once 'public/shortcode/shortcode.php';
}
}
//End Of Freemius |