PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.2
Vimeography: Vimeo Video Gallery WordPress Plugin v2.2
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / lib / admin / actions.php

actions.php in Vimeography: Vimeo Video Gallery WordPress Plugin 2.2, at lib/admin/actions.php

136 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 class Vimeography_Admin_Actions {
7
8 public function __construct() {
9 add_action( 'admin_init', array( $this, 'vimeography_requires_wordpress_version') );
10 add_action( 'admin_init', array( $this, 'vimeography_maybe_add_activation_key_reset_nag') );
11 add_action( 'admin_init', array( $this, 'vimeography_maybe_add_pro_update_nag') );
12
13 add_action( 'vc_before_init', array( $this, 'register_visual_composer_element') );
14 }
15
16 /**
17 * Register a custom element for use in WPBakery Page Builder.
18 * (formally Visual Composer)
19 *
20 * @since 2.0
21 */
22 public function register_visual_composer_element() {
23
24 if ( ! function_exists('vc_map') ) {
25 return;
26 }
27
28 global $wpdb;
29 $galleries = $wpdb->get_results('SELECT id, title FROM '. $wpdb->vimeography_gallery);
30
31 if ( empty( $galleries ) ) {
32 return;
33 }
34
35 $values = array();
36
37 foreach( $galleries as $gallery ) {
38 $values[$gallery->title] = $gallery->id;
39 }
40
41 vc_map( array(
42 'name' => __('Vimeography Gallery', 'vimeography'),
43 'description' => __('Add a Vimeography Gallery to this page.', 'vimeography'),
44 'base' => 'vimeography',
45 'icon' => VIMEOGRAPHY_URL . 'lib/admin/assets/img/vimeography-logo-512px-transparent.png',
46 'category' => 'Content',
47 'params' => array(
48 array(
49 'type' => 'dropdown',
50 'heading' => __('Choose your Gallery', 'vimeography'),
51 'param_name' => 'id',
52 'description' => __('To create a new gallery, visit the Vimeography Gallery Editor.', 'vimeography'),
53 'value' => $values,
54 'std' => $galleries[0]->title,
55 'admin_label' => true,
56 ),
57 )
58 ) );
59 }
60
61
62 /**
63 * Check the wordpress version is compatible, and disable plugin if not.
64 *
65 * @access public
66 * @return void
67 */
68 public function vimeography_requires_wordpress_version() {
69 global $wp_version;
70
71 if ( version_compare($wp_version, "3.3", "<" ) ) {
72 if ( is_plugin_active( VIMEOGRAPHY_BASENAME ) ) {
73 deactivate_plugins( VIMEOGRAPHY_BASENAME );
74 wp_die( sprintf( __('Vimeography requires WordPress 3.3 or higher. Please upgrade WordPress and try again. <a href="%s">Back to WordPress admin</a>', 'vimeography'), admin_url() ) );
75 }
76 }
77 }
78
79 /**
80 * Adds a notice if the user needs to remove and reenter their license keys
81 * @return void
82 */
83 public function vimeography_maybe_add_activation_key_reset_nag() {
84 if ( get_site_option('vimeography_corrupt_keys_found') ) {
85 if ( isset( $_GET['vimeography-cancel-activation-message'] ) OR get_site_option('vimeography_activation_keys') ) {
86 delete_site_option('vimeography_corrupt_keys_found');
87 return;
88 }
89
90 if ( ! isset( $_POST['vimeography-activate-key'] ) ) {
91 add_action('admin_notices', array($this, 'vimeography_corrupt_keys_notice') );
92 }
93 }
94 }
95
96 /**
97 * Outputs a notice if the user needs to remove and reenter their license keys
98 * @return void
99 */
100 public function vimeography_corrupt_keys_notice() {
101 printf( '<div class="update-nag"> <p> %1$s | <a href="%2$s"> %3$s </a> </p> </div>',
102 sprintf( __( "<strong>Notice:</strong> Vimeography found a problem with the way your Vimeography Activation Keys were saved. To resolve this error, please visit the <a href=\"%s\" title=\"Vimeography Manage Activations Page\">Vimeography Manage Activations page</a> and re-enter your activation keys that you received via email while purchasing your Vimeography products.", 'vimeography' ), admin_url('admin.php?page=vimeography-manage-activations') ),
103 esc_url( add_query_arg( 'vimeography-cancel-activation-message', wp_create_nonce( 'wptus_nag' ) ) ),
104 __( 'Dismiss', 'vimeography' )
105 );
106 }
107
108 /**
109 * Yells at the user to upgrade their
110 * Pro plugin if it is installed and out of date.
111 *
112 * @return void
113 */
114 public function vimeography_maybe_add_pro_update_nag() {
115 $pro_version = get_option('vimeography_pro_db_version');
116
117 if ($pro_version) {
118 if ( version_compare($pro_version, '0.7', '<') ) {
119 add_action('admin_notices', array($this, 'vimeography_pro_upgrade_notice') );
120 }
121 }
122 }
123
124 /**
125 * Adds the update message for outdated Pro versions.
126 *
127 * @return string | html
128 */
129 public function vimeography_pro_upgrade_notice() {
130 printf( '<div class="update-nag">%1$s</div>',
131 sprintf( __( "<strong>Hey!</strong> It looks like there is an update ready for Vimeography Pro. Make sure you've entered your <a href=\"%s\" title=\"Vimeography Manage Activations Page\">activation key</a>, then head on over to the <a href=\"%s\" title=\"Plugins Page\">Plugins page</a> to get the latest compatible version.", 'vimeography' ), admin_url('admin.php?page=vimeography-manage-activations'), admin_url('update-core.php?force-check=1') )
132 );
133 }
134
135 }
136