-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,874 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/node_modules | ||
/languages | ||
/build | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Gruntfile | ||
*/ | ||
|
||
module.exports = function (grunt) { | ||
|
||
// Grunt configuration | ||
var config = { | ||
pkg: grunt.file.readJSON('package.json'), | ||
|
||
makepot: { | ||
target: { | ||
options: { | ||
type: 'wp-plugin', | ||
domainPath: '/languages' | ||
} | ||
} | ||
}, | ||
|
||
copy: { | ||
main: { | ||
expand: true, | ||
src: [ | ||
'**', | ||
'!.*', | ||
'!.git/**', | ||
'!README.md', | ||
'!node_modules/**', | ||
'!package.json', | ||
'!package-lock.json', | ||
'!Gruntfile.js', | ||
'!composer.json', | ||
'!composer.lock', | ||
'!vendor/**', | ||
], | ||
dest: './build' | ||
} | ||
}, | ||
|
||
clean: ['./build'] | ||
}; | ||
|
||
//init grunt | ||
grunt.initConfig(config); | ||
|
||
//Load Tasks | ||
grunt.loadNpmTasks('grunt-wp-i18n'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
|
||
//Register Tasks | ||
grunt.registerTask('default', ['makepot']); | ||
grunt.registerTask('build', ['default', 'clean', 'copy']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# classic-widgets-with-block-based-widgets | ||
Restore the classic widgets screen as a new menu item without replacing new block-based widgets. | ||
# Classic Widgets with Block-based Widgets | ||
|
||
<p align="center"><a href="https://wordpress.org/plugins/classic-widgets-with-block-based-widgets/"><img alt="Classic Widgets with Block-based Widgets" src="https://ps.w.org/classic-widgets-with-block-based-widgets/assets/banner-1544x500.png?rev=2861054" /></a></p> | ||
|
||
*Classic Widgets with Block-based Widgets* allows you to use both widgets screens at the same time. | ||
Sometimes, you need to use the classic widget screen for some of the widgets without permanently disabling the block-based widgets. With this plugin, you can access the Classic Widgets screen in `Appearance > Classic Widgets` and the block-based screen at the usual place in `Appearance > Widgets`. | ||
|
||
>This plugin uses WordPress filters to create a new classic widget screen. That means it will work as long as WordPress supports the Classic Widgets screen. | ||
## Contributing | ||
If you have spotted an issue or want to suggest a new feature then please submit a new issue or if you want to submit a patch then please send a pull request. | ||
|
||
## Useful Links | ||
* [Latest Release](https://github.com/5um17/classic-widgets-with-block-based-widgets/releases/latest) | ||
* [WP Plugin Page](https://wordpress.org/plugins/classic-widgets-with-block-based-widgets/) | ||
* [Support](https://wordpress.org/support/plugin/classic-widgets-with-block-based-widgets/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Classic Widgets with Block-based Widgets | ||
* Plugin URI: https://www.secretsofgeeks.com/ | ||
* Description: Restore the classic widgets screen as a new menu item without replacing new block-based widgets. | ||
* Version: 1.0.1 | ||
* Author: 5um17 | ||
* Author URI: https://www.secretsofgeeks.com | ||
* Text Domain: classic-widgets-with-block-based-widgets | ||
* | ||
* @package CBW | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
if ( ! defined( 'CLASSIC_AND_BLOCK_WIDGETS_FILENAME' ) ) { | ||
define( 'CLASSIC_AND_BLOCK_WIDGETS_FILENAME', plugin_basename( __FILE__ ) ); | ||
} | ||
|
||
add_action( | ||
'plugins_loaded', | ||
function () { | ||
if ( cbw_request_uri_contain( '/wp-admin/widgets.php' ) ) { | ||
// If this is widget.php screen, set or delete transient based on cw query string. | ||
! empty( $_GET['cw'] ) ? set_transient( 'classic_and_block_widgets', true, HOUR_IN_SECONDS ) : delete_transient( 'classic_and_block_widgets' ); | ||
} | ||
|
||
// Add actual filters to disable block based widgets based on transients. | ||
if ( get_transient( 'classic_and_block_widgets' ) ) { | ||
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' ); | ||
add_filter( 'use_widgets_block_editor', '__return_false' ); | ||
} | ||
|
||
// Add the new menu under appearance. | ||
add_action( | ||
'admin_menu', | ||
function() { | ||
add_submenu_page( 'themes.php', __( 'Classic Widgets', 'classic-widgets-with-block-based-widgets' ), __( 'Classic Widgets', 'classic-widgets-with-block-based-widgets' ), 'edit_theme_options', 'widgets.php?cw=1', null, 3 ); | ||
|
||
// Handle current menu class. | ||
add_filter( | ||
'submenu_file', | ||
function( $submenu_file ) { | ||
if ( cbw_request_uri_contain( 'widgets.php?cw=1' ) ) { | ||
global $self; | ||
$self = 'widgets.php?cw=1'; | ||
} | ||
return $submenu_file; | ||
} | ||
); | ||
} | ||
); | ||
|
||
// Plugin row meta data. | ||
add_filter( | ||
'plugin_row_meta', | ||
function ( $links, $file ) { | ||
if ( CLASSIC_AND_BLOCK_WIDGETS_FILENAME !== $file ) { | ||
return $links; | ||
} | ||
|
||
if ( is_array( $links ) ) { | ||
$links[] = '<a href="https://wordpress.org/plugins/search/5um17/" target="_blank">' | ||
. __( 'More Plugins', 'classic-widgets-with-block-based-widgets' ) | ||
. '</a>'; | ||
} | ||
return $links; | ||
}, | ||
10, | ||
2 | ||
); | ||
|
||
// Classic widgets link in plugin row actions. | ||
add_filter( | ||
'plugin_action_links_' . CLASSIC_AND_BLOCK_WIDGETS_FILENAME, | ||
function ( $links ) { | ||
if ( is_array( $links ) ) { | ||
$links[] = '<a href="' . admin_url( 'widgets.php?cw=1' ) . '">' | ||
. __( 'Classic Widgets', 'classic-widgets-with-block-based-widgets' ) | ||
. '</a>'; | ||
} | ||
|
||
return $links; | ||
} | ||
); | ||
} | ||
); | ||
|
||
/** | ||
* Check if REQUEST_URI exist and contains the given value. | ||
* | ||
* @since 1.0 | ||
* @param string $needle Needle to search. | ||
* @return boolean true if needle found else false. | ||
*/ | ||
function cbw_request_uri_contain( $needle ) { | ||
if ( ! empty( $_SERVER['REQUEST_URI'] ) && false !== strpos( $_SERVER['REQUEST_URI'], $needle ) ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "5um17/classic-widgets-with-block-based-widgets", | ||
"description": "Restore the classic widgets screen as a new menu item without replacing new block-based widgets.", | ||
"type": "wordpress-plugin", | ||
"license": "GPL-3.0+", | ||
"authors": [ | ||
{ | ||
"name": "5um17", | ||
"email": "5um17@secretsofgeeks.com" | ||
} | ||
], | ||
"scripts": { | ||
"wpcs" : ".\\vendor\\bin\\phpcs --colors --standard=WordPress-Core,WordPress-Docs", | ||
"wpcb" : ".\\vendor\\bin\\phpcbf --standard=WordPress-Core,WordPress-Docs" | ||
}, | ||
"require": { | ||
}, | ||
"require-dev": { | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", | ||
"wp-coding-standards/wpcs": "^2.3", | ||
"squizlabs/php_codesniffer": "^3.5" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
Oops, something went wrong.