Skip to content

Commit 53ffcb6

Browse files
authored
Merge pull request #67 from dartiss/develop
Version 2.3.9
2 parents 49e4a55 + 8572685 commit 53ffcb6

File tree

10 files changed

+163
-71
lines changed

10 files changed

+163
-71
lines changed

assets/blueprints/blueprint.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"landingPage": "\/wp-admin\/options-general.php?page=ce-options",
3+
"preferredVersions": {
4+
"php": "8.0",
5+
"wp": "latest"
6+
},
7+
"phpExtensionBundles": [
8+
"kitchen-sink"
9+
],
10+
"features": {
11+
"networking": true
12+
},
13+
"steps": [
14+
{
15+
"step": "installPlugin",
16+
"pluginZipFile": {
17+
"resource": "url",
18+
"url": "https:\/\/downloads.wordpress.org\/plugin\/simple-embed-code.zip"
19+
},
20+
"options": {
21+
"activate": true
22+
}
23+
},
24+
{
25+
"step": "login",
26+
"username": "admin",
27+
"password": "password"
28+
}
29+
]
30+
}

assets/icon-128x128.png

-154 Bytes
Loading

assets/icon-256x256.png

-128 Bytes
Loading

assets/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/screenshot-1.png

-10.2 KB
Loading

includes/add-embeds.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function ce_quick_replace( $content = '', $options = '', $search = '' ) {
169169
*/
170170
function ce_generate_code( $html, $responsive = '', $max_width = '' ) {
171171

172-
$code = "\n";
172+
$code = '';
173173

174174
if ( false !== $max_width ) {
175175
$code .= '<div style="width: ' . $max_width . 'px; max-width: 100%">';
@@ -189,8 +189,6 @@ function ce_generate_code( $html, $responsive = '', $max_width = '' ) {
189189
$code .= '</div>';
190190
}
191191

192-
$code .= "\n";
193-
194192
return $code;
195193
}
196194

includes/admin-config.php renamed to includes/screens.php

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,12 @@
11
<?php
22
/**
3-
* Administration Menu Options
3+
* Add screens
44
*
5-
* Add various adminstration menu options
5+
* Add settings and tools screens.
66
*
77
* @package simple-embed-code
88
*/
99

10-
/**
11-
* Add Settings link to plugin list
12-
*
13-
* Add a Settings link to the options listed against this plugin
14-
*
15-
* @param string $links Current links.
16-
* @param string $file File in use.
17-
* @return string Links, now with settings added.
18-
*/
19-
function ce_add_settings_link( $links, $file ) {
20-
21-
static $this_plugin;
22-
23-
if ( ! $this_plugin ) {
24-
$this_plugin = plugin_basename( __FILE__ );
25-
}
26-
27-
if ( false !== strpos( $file, 'code-embed.php' ) ) {
28-
$settings_link = '<a href="admin.php?page=ce-options">' . __( 'Settings', 'simple-embed-code' ) . '</a>';
29-
array_unshift( $links, $settings_link );
30-
}
31-
32-
return $links;
33-
}
34-
35-
add_filter( 'plugin_action_links', 'ce_add_settings_link', 10, 2 );
36-
37-
/**
38-
* Add meta to plugin details
39-
*
40-
* Add options to plugin meta line
41-
*
42-
* @param string $links Current links.
43-
* @param string $file File in use.
44-
* @return string Links, now with settings added.
45-
*/
46-
function ce_set_plugin_meta( $links, $file ) {
47-
48-
if ( false !== strpos( $file, 'code-embed.php' ) ) {
49-
50-
$links = array_merge( $links, array( '<a href="https://github.com/dartiss/code-embed">' . __( 'Github', 'simple-embed-code' ) . '</a>' ) );
51-
52-
$links = array_merge( $links, array( '<a href="https://wordpress.org/plugins/simple-embed-code/">' . __( 'Support', 'simple-embed-code' ) . '</a>' ) );
53-
54-
$links = array_merge( $links, array( '<a href="https://artiss.blog/donate">' . __( 'Donate', 'simple-embed-code' ) . '</a>' ) );
55-
56-
$links = array_merge( $links, array( '<a href="https://wordpress.org/support/plugin/simple-embed-code/reviews/#new-post">' . __( 'Write a Review', 'simple-embed-code' ) . '&nbsp;⭐️⭐️⭐️⭐️⭐️</a>' ) );
57-
}
58-
59-
return $links;
60-
}
61-
62-
add_filter( 'plugin_row_meta', 'ce_set_plugin_meta', 10, 2 );
63-
6410
/**
6511
* Code Embed Menu
6612
*

includes/shared.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
/**
11+
* Add meta to plugin details
12+
*
13+
* Add options to plugin meta line
14+
*
15+
* @version 1.1
16+
* @param string $links Current links.
17+
* @param string $file File in use.
18+
* @return string Links, now with settings added.
19+
*/
20+
function sec_plugin_meta( $links, $file ) {
21+
22+
if ( false !== strpos( $file, 'simple-code-embed.php' ) ) {
23+
24+
$links = array_merge(
25+
$links,
26+
array( '<a href="https://github.com/dartiss/code-embed">' . __( 'Github', 'simple-embed-code' ) . '</a>' ),
27+
array( '<a href="https://wordpress.org/support/plugin/simple-embed-code">' . __( 'Support', 'simple-embed-code' ) . '</a>' ),
28+
array( '<a href="https://artiss.blog/donate">' . __( 'Donate', 'simple-embed-code' ) . '</a>' ),
29+
array( '<a href="https://wordpress.org/support/plugin/simple-embed-code/reviews/?filter=5" title="' . __( 'Rate the plugin on WordPress.org', 'simple-embed-code' ) . '" style="color: #ffb900">' . str_repeat( '<span class="dashicons dashicons-star-filled" style="font-size: 16px; width:16px; height: 16px"></span>', 5 ) . '</a>' ),
30+
);
31+
}
32+
33+
return $links;
34+
}
35+
36+
add_filter( 'plugin_row_meta', 'sec_plugin_meta', 10, 2 );
37+
38+
/**
39+
* Modify actions links.
40+
*
41+
* Add or remove links for the actions listed against this plugin
42+
*
43+
* @version 1.1
44+
* @param string $actions Current actions.
45+
* @param string $plugin_file The plugin.
46+
* @return string Actions, now with deactivation removed!
47+
*/
48+
function sec_action_links( $actions, $plugin_file ) {
49+
50+
// Make sure we only perform actions for this specific plugin!
51+
if ( strpos( $plugin_file, 'simple-code-embed.php' ) !== false ) {
52+
53+
// Add link to the settings page.
54+
if ( current_user_can( 'manage_options' ) ) {
55+
array_unshift( $actions, '<a href="admin.php?page=ce-options">' . __( 'Settings', 'simple-embed-code' ) . '</a>' );
56+
}
57+
}
58+
59+
return $actions;
60+
}
61+
62+
add_filter( 'plugin_action_links', 'sec_action_links', 10, 2 );
63+
64+
/**
65+
* WordPress Fork Check
66+
*
67+
* Deactivate the plugin if an unsupported fork of WordPress is detected.
68+
*
69+
* @version 1.0
70+
*/
71+
function sec_fork_check() {
72+
73+
// Check for a fork.
74+
75+
if ( function_exists( 'calmpress_version' ) || function_exists( 'classicpress_version' ) ) {
76+
77+
// Grab the plugin details.
78+
79+
$plugins = get_plugins();
80+
$name = $plugins[ CODE_EMBED_PLUGIN_BASE ]['Name'];
81+
82+
// Deactivate this plugin.
83+
84+
deactivate_plugins( CODE_EMBED_PLUGIN_BASE );
85+
86+
// Set up a message and output it via wp_die.
87+
88+
/* translators: 1: The plugin name. */
89+
$message = '<p><b>' . sprintf( __( '%1$s has been deactivated', 'simple-embed-code' ), $name ) . '</b></p><p>' . __( 'Reason:', 'simple-embed-code' ) . '</p>';
90+
/* translators: 1: The plugin name. */
91+
$message .= '<ul><li>' . __( 'A fork of WordPress was detected.', 'simple-embed-code' ) . '</li></ul><p>' . sprintf( __( 'The author of %1$s will not provide any support until the above are resolved.', 'simple-embed-code' ), $name ) . '</p>';
92+
93+
$allowed = array(
94+
'p' => array(),
95+
'b' => array(),
96+
'ul' => array(),
97+
'li' => array(),
98+
);
99+
100+
wp_die( wp_kses( $message, $allowed ), '', array( 'back_link' => true ) );
101+
}
102+
}
103+
104+
add_action( 'admin_init', 'sec_fork_check' );

readme.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
=== Code Embed ===
22
Contributors: dartiss
33
Donate link: https://artiss.blog/donate
4-
Tags: code, embed, html, css, javascript, script
4+
Tags: code, embed, html, css, javascript
55
Requires at least: 4.6
6-
Tested up to: 6.4
6+
Tested up to: 6.5
77
Requires PHP: 7.4
8-
Stable tag: 2.3.8
8+
Stable tag: 2.3.9
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

12-
🧩 Code Embed provides a very easy and efficient way to embed code (JavaScript, CSS and HTML) in your posts and pages.
12+
Code Embed provides a very easy and efficient way to embed code (JavaScript, CSS and HTML) in your posts and pages.
1313

1414
== Description ==
1515

@@ -26,9 +26,9 @@ Key features include...
2626
* Embed an external script directly using just the URL
2727
* And much, much more!
2828

29-
Iconography is courtesy of the very talented [Janki Rathod](https://www.fiverr.com/jankirathore) ♥️
29+
Iconography is courtesy of the very talented [Janki Rathod](https://www.fiverr.com/jankirathore).
3030

31-
👉 Please visit the [Github page](https://github.com/dartiss/code-embed "Github") for the latest code development, planned enhancements and known issues 👈
31+
**Please visit the [Github page](https://github.com/dartiss/code-embed "Github") for the latest code development, planned enhancements and known issues**
3232

3333
== Getting Started ==
3434

@@ -195,6 +195,11 @@ It is, in that it doesn't save any data that could be odds with GDPR compliance
195195

196196
I use semantic versioning, with the first release being 1.0.
197197

198+
= 2.3.9 =
199+
* Enhancement: So, let me tell you a story. To make the output look neat, I was adding carriage returns to the embeds. Except, if you want to embed something part way through a line it can look... well... wrong. And all for it looking clean. Remember kids, cleanlyness isn't always next to Godlyness. Needless to say, those rogue carriage returns are gone
200+
* Enhancement: Whilst I was at it, I updated some of the settings code to a brand-spanking new version, which I'm sharing across all my plugins
201+
* Enhancement: Tidied up some of the assets, including adding a blueprint for WordPress Playground
202+
198203
= 2.3.8 =
199204
* Bug: You know that vulnerability I fixed in 2.3.7? It fixed that but broke something else. That should now resolved. Apologies for that.
200205

@@ -327,5 +332,5 @@ versions of this plugin
327332

328333
== Upgrade Notice ==
329334

330-
= 2.3.8 =
331-
* Critical bug fix
335+
= 2.3.9 =
336+
* Minor improvement to output to elliminate unwanted carriage returns

simple-code-embed.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*
99
* Plugin Name: Code Embed
1010
* Plugin URI: https://wordpress.org/plugins/simple-embed-code/
11-
* Description: 🧩 Code Embed provides a very easy and efficient way to embed code (JavaScript and HTML) in your posts and pages.
12-
* Version: 2.3.8
11+
* Description: Code Embed provides a very easy and efficient way to embed code (JavaScript and HTML) in your posts and pages.
12+
* Version: 2.3.9
1313
* Requires at least: 4.6
1414
* Requires PHP: 7.4
1515
* Author: David Artiss
@@ -26,7 +26,13 @@
2626
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2727
*/
2828

29-
define( 'CODE_EMBED_VERSION', '2.3.8' );
29+
define( 'CODE_EMBED_VERSION', '2.3.9' );
30+
31+
// Define global to hold the plugin base file name.
32+
33+
if ( ! defined( 'CODE_EMBED_PLUGIN_BASE' ) ) {
34+
define( 'CODE_EMBED_PLUGIN_BASE', plugin_basename( __FILE__ ) );
35+
}
3036

3137
// Include all the various functions.
3238

@@ -36,7 +42,9 @@
3642

3743
if ( is_admin() ) {
3844

39-
require_once $functions_dir . 'admin-config.php'; // Various administration config. options.
45+
require_once $functions_dir . 'shared.php'; // Functions shared across all my plugins.
46+
47+
require_once $functions_dir . 'screens.php'; // Add settings and tools screens.
4048

4149
} else {
4250

0 commit comments

Comments
 (0)