Skip to content

Commit

Permalink
Merge pull request #112 from 10up/feature/bulk-scan-fix-from-admin
Browse files Browse the repository at this point in the history
Bulk scan/fix for insecure content from the admin
  • Loading branch information
jeffpaul authored Aug 8, 2023
2 parents 911e038 + bf5af8e commit 494aa7d
Show file tree
Hide file tree
Showing 25 changed files with 8,507 additions and 555 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ src/js/shared/vendor
gulp-tasks/
webpack.config.babel.js
gulpfile.babel.js
node_modules/
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: { jquery: true },
extends: ['@10up/eslint-config/wordpress'],
settings: {
'import/core-modules': [ 'jquery' ]
},
rules: {
'react/no-array-index-key': 'off',
'jsdoc/newline-after-description': 'off',
"react/jsx-indent" : ["error", 0],
"react/jsx-indent-props" : ["error", 0],
},
globals: {
module: true,
process: true,
wp: true,
jquery: true,
tinyMCE: true,
insecureContentAdmin: true,
},
};
14 changes: 0 additions & 14 deletions .eslintrc.json

This file was deleted.

12 changes: 6 additions & 6 deletions config/webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const settings = require('./webpack.settings.js');
/**
* Configure entries.
*
* @return {Object[]} Array of webpack settings.
* @returns {object[]} Array of webpack settings.
*/
const configureEntries = () => {
const entries = {};
Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = {
enforce: 'pre',
loader: 'eslint-loader',
options: {
fix: true,
fix: false,
},
},

Expand Down Expand Up @@ -155,14 +155,14 @@ module.exports = {
// Fancy WebpackBar.
new WebpackBar(),

new DependencyExtractorWebpackPlugin( {
new DependencyExtractorWebpackPlugin({
injectPolyfill: false,
combineAssets: false,
requestToExternal( request ) {
if ( request === 'underscore' ) {
requestToExternal(request) {
if (request === 'underscore') {
return '_';
}
},
} ),
}),
],
};
1 change: 1 addition & 0 deletions config/webpack.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module.exports = {
entries: {
// JS files.
admin: './src/js/admin.js',
gutenberg: './src/js/gutenberg.js',
'classic-editor': './src/js/classic-editor.js',

Expand Down
7,222 changes: 7,221 additions & 1 deletion dist/js/gutenberg.js

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions includes/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Insecure Content Warning assets
*
* @package ICW
*/

namespace ICW\Admin;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

/**
* Setup actions and filters
*/
function setup() {
add_action( 'admin_menu', __NAMESPACE__ . '\\admin_menu' );
}

/**
* Register the admin menu.
*
* @return void
*/
function admin_menu() {
$hook = add_management_page(
__( 'Insecure Content Warning Admin', 'insecure-content-warning' ),
__( 'Insecure Content Warning', 'insecure-content-warning' ),
'edit_posts',
'insecure-content-warning',
__NAMESPACE__ . '\\admin_page'
);

add_action( 'admin_print_scripts-' . $hook, 'ICW\Assets\admin_scripts' );
}

/**
* Load the admin page template.
*
* @return void
*/
function admin_page() {
require_once __DIR__ . '/partials/admin-page.php';
}
24 changes: 24 additions & 0 deletions includes/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@ function enqueue_scripts( $hook = '' ) {
}
}

/**
* Enqueue admin-only JavaScript/CSS
*/
function admin_scripts() {
$asset_file = INSECURE_CONTENT_PATH . 'dist/js/admin.asset.php';
if ( file_exists( $asset_file ) ) {
$asset = require_once $asset_file;
wp_enqueue_script(
'insecure-content-admin',
INSECURE_CONTENT_URL . 'dist/js/admin.js',
$asset['dependencies'],
$asset['version'],
true
);

wp_enqueue_style(
'insecure-content-admin',
INSECURE_CONTENT_URL . 'dist/css/admin-style.css',
false,
$asset['version'],
);
}
}

/**
* Display a notice about JS and CSS assets missing
*
Expand Down
Loading

0 comments on commit 494aa7d

Please sign in to comment.