PluginProbe
Code Embed / 2.6.4
Code Embed v2.6.4
2.6.4 2.6.3 2.6.2 2.6.1 trunk 1.0 1.1 1.2 1.3 1.4.1 1.5.1 1.6.1 2.0.2 2.1.2 2.2.2 2.3.9 2.4 2.5.1 2.5.2 2.6
simple-embed-code / includes / shared.php

shared.php in Code Embed 2.6.4, at includes/shared.php

122 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shared Functions
4 *
5 * A group of functions shared across my plugins, for consistency.
6 *
7 * @package simple-embed-code
8 */
9
10 // Exit if accessed directly.
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Add meta to plugin details
18 *
19 * Add options to plugin meta line.
20 *
21 * Internal code version: 1.3
22 *
23 * @param array $links Current links.
24 * @param string $file File in use.
25 * @return array Links, now with settings added.
26 */
27 function sec_plugin_meta( $links, $file ) {
28
29 if ( CODE_EMBED_PLUGIN_BASE === $file ) {
30
31 $links = array_merge(
32 $links,
33 array( '<a href="' . esc_url( 'https://github.com/dartiss/code-embed' ) . '">' . __( 'Github', 'simple-embed-code' ) . '</a>' ),
34 array( '<a href="' . esc_url( 'https://wordpress.org/support/plugin/simple-embed-code' ) . '">' . __( 'Support', 'simple-embed-code' ) . '</a>' ),
35 array( '<a href="' . esc_url( 'https://wordpress.org/support/plugin/simple-embed-code/reviews/' ) . '">' . __( 'Write a Review', 'simple-embed-code' ) . '</a>' ),
36 array( '<a href="' . esc_url( 'https://artiss.blog/donate' ) . '">' . __( 'Donate', 'simple-embed-code' ) . '</a>' ),
37 );
38 }
39
40 return $links;
41 }
42
43 add_filter( 'plugin_row_meta', 'sec_plugin_meta', 10, 2 );
44
45 /**
46 * Modify action links.
47 *
48 * Add links for the actions listed against this plugin.
49 *
50 * Internal code version: 1.1
51 *
52 * @param array $actions Current actions.
53 * @param string $plugin_file The plugin.
54 * @return array List of plugin actions.
55 */
56 function sec_action_links( $actions, $plugin_file ) {
57
58 // Make sure we only perform actions for this specific plugin!
59 if ( CODE_EMBED_PLUGIN_BASE === $plugin_file ) {
60
61 // Add link to the settings page.
62 if ( current_user_can( 'manage_options' ) ) {
63 array_unshift( $actions, '<a href="' . admin_url( 'options-general.php?page=ce-options' ) . '">' . __( 'Settings', 'simple-embed-code' ) . '</a>' );
64 }
65 }
66
67 return $actions;
68 }
69
70 add_filter( 'plugin_action_links', 'sec_action_links', 10, 2 );
71
72 /**
73 * WordPress Requirements Check
74 *
75 * Deactivate the plugin if certain requirements are not met.
76 *
77 * Internal code version: 1.1
78 */
79 function sec_requirements_check() {
80
81 $reason = '';
82
83 // Grab the plugin details.
84
85 $plugins = get_plugins();
86 $name = $plugins[ CODE_EMBED_PLUGIN_BASE ]['Name'];
87
88 // Check for a fork.
89
90 if ( function_exists( 'calmpress_version' ) || function_exists( 'classicpress_version' ) ) {
91
92 /* translators: 1: The plugin name. */
93 $reason .= '<li>' . sprintf( __( 'A fork of WordPress was detected. %1$s has not been tested on this fork and, as a consequence, the author will not provide any support.', 'simple-embed-code' ), $name ) . '</li>';
94
95 }
96
97 // If a requirement is not met, output the message and stop the plugin.
98
99 if ( '' !== $reason ) {
100
101 // Deactivate this plugin.
102
103 deactivate_plugins( CODE_EMBED_PLUGIN_BASE );
104
105 // Set up a message and output it via wp_die.
106
107 /* translators: 1: The plugin name. */
108 $message = '<p><strong>' . sprintf( __( '%1$s has been deactivated', 'simple-embed-code' ), $name ) . '</strong></p><p>' . __( 'Reason:', 'simple-embed-code' ) . '</p><ul>' . $reason . '</ul>';
109
110 $allowed = array(
111 'p' => array(),
112 'b' => array(),
113 'ul' => array(),
114 'li' => array(),
115 );
116
117 wp_die( wp_kses( $message, $allowed ), '', array( 'back_link' => true ) );
118 }
119 }
120
121 add_action( 'admin_init', 'sec_requirements_check' );
122