Skip to content

Commit

Permalink
some code cleanup, add some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardCoffee committed Mar 23, 2020
1 parent caae9e6 commit 66a520c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 133 deletions.
22 changes: 14 additions & 8 deletions classes/Options/Privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function options_layout( $all = false ) {
$this->initialize();
$layout = array( 'default' => true );
$warning = _x( '*** Turning off reporting a %1$s means you will not be notified of upgrades for that %1$s! ***', 'noun - singular', 'privacy-my-way' );
$extra_html = array( 'yes' => ' <span class="red"> ' . __( ' ( Recommended ) ', 'privacy-my-way' ) . '</span>' );
$extra_html = array( 'yes' => ' <span class="red"> ' . esc_html_x( ' ( Recommended ) ', 'Added to a string to indicate the recommended option', 'privacy-my-way' ) . '</span>' );
$layout['blog'] = array(
'default' => 'yes',
'label' => __( 'Blog URL', 'privacy-my-way' ),
Expand Down Expand Up @@ -72,7 +72,6 @@ protected function options_layout( $all = false ) {
),
);
if ( ( is_multisite() && is_main_site() ) || $all ) {
$layout['blog']['change'] = 'showhidePosi( this, ".privacy-blog-option", "yes" );';
$layout['blog']['showhide'] = array(
'origin' => 'privacy-blog-active',
'target' => 'privacy-blog-option',
Expand All @@ -92,7 +91,6 @@ protected function options_layout( $all = false ) {
'target' => 'privacy-multi-option',
'show' => 'yes',
),
'change' => 'showhidePosi( this, ".privacy-multi-option", "yes" );',
'divcss' => 'privacy-multi-active privacy-blog-option',
); //*/
$layout['install'] = array(
Expand Down Expand Up @@ -129,7 +127,11 @@ protected function options_layout( $all = false ) {
'filter' => __( 'Filter the plugin list that gets sent to WordPress.', 'privacy-my-way' ),
'none' => __( 'Do not let them know about your plugins.', 'privacy-my-way' ),
),
'change' => 'showhidePosi( this, ".privacy-plugin-filter", "filter" );',
'showhide' => array(
'origin' => 'privacy-plugin-active',
'target' => 'privacy-plugin-filter',
'show' => 'filter'
),
'divcss' => 'privacy-plugin-active',
); //*/
$layout['install_default'] = array(
Expand All @@ -149,7 +151,7 @@ protected function options_layout( $all = false ) {
'preset' => 'yes',
'label' => __( 'Plugin List', 'privacy-my-way' ),
'text' => sprintf( $warning, __( 'plugin', 'privacy-my-way' ) ),
'textcss' => 'red', // FIXME: bad css
'textcss' => 'red',
'render' => 'radio_multiple',
'source' => $this->get_plugin_list(),
'divcss' => 'privacy-plugin-filter',
Expand All @@ -164,15 +166,19 @@ protected function options_layout( $all = false ) {
'filter' => __( 'Filter the theme list that gets sent to WordPress.', 'privacy-my-way' ),
'none' => __( 'Do not let them know about your themes.', 'privacy-my-way' ),
),
'change' => 'showhidePosi(this,".privacy-theme-filter","filter");',
'showhide' => array(
'origin' => 'privacy-theme-active',
'target' => 'privacy-theme-filter',
'show' => 'filter',
),
'divcss' => 'privacy-theme-active',
); //*/
$layout['theme_list'] = array(
'default' => $this->get_theme_defaults(),
'preset' => 'yes',
'label' => __( 'Theme List', 'privacy-my-way' ),
'text' => sprintf( $warning, __( 'theme', 'privacy-my-way' ) ),
'textcss' => 'red', // FIXME: bad css
'textcss' => 'red',
'postext' => __( 'The WordPress twenty* themes that are installed will always be reported.', 'privacy-my-way' ),
'help' => __( 'This plugin does not filter default WordPress themes.', 'privacy-my-way' ),
'render' => 'radio_multiple',
Expand Down Expand Up @@ -223,7 +229,7 @@ protected function options_layout( $all = false ) {
'nodelete' => __( 'Always retain the plugin data.', 'privacy-my-way' ),
),
);
return apply_filters( "tcc_options_layout_{$this->base}", $layout );
return $layout;
}


Expand Down
4 changes: 2 additions & 2 deletions classes/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct() {

add_filter( 'core_version_check_query_args', [ $this, 'core_version_check_query_args' ] );

# These next two filters are multisite only
// These next two filters are multisite only
add_filter( 'pre_site_option_blog_count', [ $this, 'pre_site_option_blog_count' ], 10, 3 );
add_filter( 'pre_site_option_user_count', [ $this, 'pre_site_option_user_count' ], 10, 3 );

Expand Down Expand Up @@ -433,7 +433,7 @@ public function plugins_site_transient( $value, $transient ) {
if ( $this->options['plugins'] === 'filter' ) {
foreach( $this->options['plugin_list'] as $plugin => $state ) {
if ( $state === 'no' ) {
if ( array_key_exists( $plugin, $value->checked ) ) {
if ( property_exists( $value, 'checked' ) && array_key_exists( $plugin, $value->checked ) ) {
unset( $value->checked[ $plugin ] );
}
if ( array_key_exists( $plugin, $value->response ) ) {
Expand Down
44 changes: 22 additions & 22 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?php

/**
* Contains functions required for the plugin.
*
* @package Privacy_My_Way
* @subpackage Plugin
* @author Richard Coffee <[email protected]>
* @copyright 2017 Richard Coffee
* @link https://github.com/RichardCoffee/privacy-my-way/blob/master/functions.php
*/
defined( 'ABSPATH' ) || exit;

include_once( 'includes/debugging.php' );

/**
* Class autoloader.
*
* @since 20170221
* @param string $class Name of requested class.
*/
function pmw_privacy_class_loader( $class ) {
if ( substr( $class, 0, 4 ) === 'PMW_' ) {
$load = str_replace( '_', '/', substr( $class, ( strpos( $class, '_' ) + 1 ) ) );
Expand All @@ -15,6 +27,13 @@ function pmw_privacy_class_loader( $class ) {
}
spl_autoload_register( 'pmw_privacy_class_loader' ); //*/

/**
* Get plugin library class instance.
*
* @since 20170428
* @param bool $force_log Force the library to log the next entry.
* @return object The plugin library instance.
*/
function pmw( $force_log = false ) {
static $library;
if ( empty( $library ) ) {
Expand All @@ -26,22 +45,3 @@ function pmw( $force_log = false ) {
return $library;
}

/**
* Echo an escaped attribute string
*
* @since 1.0.0
*
* @param string $string
*/
if ( ! function_exists('e_esc_attr') ) {
function e_esc_attr( $string ) {
echo esc_attr( $string );
}
}

# http://stackoverflow.com/questions/14348470/is-ajax-in-wordpress
if ( ! function_exists( 'is_ajax' ) ) {
function is_ajax() {
return ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false;
}
}
100 changes: 0 additions & 100 deletions includes/debugging.php

This file was deleted.

2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Last updated on: 20200319
Last updated on: 20200323

0 comments on commit 66a520c

Please sign in to comment.