Skip to content

Commit b37c2e3

Browse files
committed
- short opentag syntax changed to extended version in backend.php
- Correct code reformat - Version updated
1 parent 5b7e5be commit b37c2e3

File tree

5 files changed

+90
-84
lines changed

5 files changed

+90
-84
lines changed

backend.php

+60-54
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function init() {
4040
add_action( 'admin_enqueue_scripts', [ $this, 'registerStartupScripts' ] );
4141

4242

43-
4443
}
4544

4645
public function about() {
@@ -51,9 +50,9 @@ public function about() {
5150
<?= __( "EUCookieLaw3 is a revamped version of the plugin EUCookieLaw.", EUCookieLaw3::LANG_DOMAIN ) ?>
5251
</p>
5352
<p>
54-
<?=sprintf(
55-
__("Read the <a href=\"%s\">on-line documentation</a>", EUCookieLaw3::LANG_DOMAIN ),
56-
'https://github.com/diegolamonica/EUCookieLaw3/'
53+
<?= sprintf(
54+
__( "Read the <a href=\"%s\">on-line documentation</a>", EUCookieLaw3::LANG_DOMAIN ),
55+
'https://github.com/diegolamonica/EUCookieLaw3/'
5756
); ?>
5857
</p>
5958
<p>
@@ -77,7 +76,7 @@ public function about() {
7776
}
7877

7978
private function buildScreen( $screen ) {
80-
add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) );
79+
add_screen_option( 'layout_columns', [ 'max' => 2, 'default' => 2 ] );
8180
?>
8281
<div class="wrap">
8382
<h2>EUCookieLaw</h2>
@@ -101,7 +100,7 @@ class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns(
101100

102101
public function settings() {
103102
$screen = WP_Screen::get();
104-
add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) );
103+
add_screen_option( 'layout_columns', [ 'max' => 2, 'default' => 2 ] );
105104
add_meta_box(
106105
'eucookielaw-banner-code' . $screen->id,
107106
__( 'Banner', EUCookieLaw3::LANG_DOMAIN ),
@@ -112,14 +111,14 @@ public function settings() {
112111
add_meta_box(
113112
'eucookielaw-message-support' . $screen->id,
114113
__( 'Support', EUCookieLaw3::LANG_DOMAIN ),
115-
array( $this, 'outputMessagesSupport' ),
114+
[ $this, 'outputMessagesSupport' ],
116115
$screen, 'side', 'high'
117116
);
118117

119118
add_meta_box(
120119
'eucookielaw-donation' . $screen->id,
121120
__( 'Donation', EUCookieLaw3::LANG_DOMAIN ),
122-
array( $this, 'donationsMetabox' ),
121+
[ $this, 'donationsMetabox' ],
123122
$screen, 'side', 'high'
124123
);
125124
$this->buildScreen( $screen );
@@ -157,25 +156,25 @@ public function donationsMetabox() {
157156
"family and your hobbies! :)", EUCookieLaw3::LANG_DOMAIN ),
158157
"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=me%40diegolamonica%2einfo&lc=IT&item_name=EU%20Cookie%20Law%203&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest",
159158
"http://amzn.eu/h0ngjnC"
160-
); ?>
159+
); ?>
161160
</p
162161
<p>
163162
<?= sprintf(
164-
__( 'You can find further informations about this plugin on <a href="%s">GitHub</a>', EUCookieLaw3::LANG_DOMAIN ), 'https://github.com/diegolamonica/EUCookieLaw3/'); ?>
163+
__( 'You can find further informations about this plugin on <a href="%s">GitHub</a>', EUCookieLaw3::LANG_DOMAIN ), 'https://github.com/diegolamonica/EUCookieLaw3/' ); ?>
165164
</p>
166165
<?php
167166
$this->displayFBLike();
168167
}
169168

170169
public function outputMessagesSupport() {
171170
?>
172-
<h3><?php _e( "Save settings", EUCookieLaw3::LANG_DOMAIN); ?></h3>
171+
<h3><?php _e( "Save settings", EUCookieLaw3::LANG_DOMAIN ); ?></h3>
173172

174173

175174
<p>
176-
<p class="eucookielaw-info-submit"><strong>EUCookieLaw version <?php echo EUCookieLaw3::VERSION ?></strong></p>
175+
<p class="eucookielaw-info-submit"><strong>EUCookieLaw version <?php echo EUCookieLaw3::VERSION ?></strong></p>
177176
<p>
178-
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( __CLASS__ ); ?>" />
177+
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( __CLASS__ ); ?>"/>
179178
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( "Save" ); ?>">
180179
</p>
181180
<?php
@@ -189,58 +188,62 @@ public function outputMessagesSupport() {
189188
}
190189

191190
public function bannerMetabox() {
192-
if ( isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], __CLASS__ ) ) {
191+
if ( isset( $_POST[ 'nonce' ] ) && wp_verify_nonce( $_POST[ 'nonce' ], __CLASS__ ) ) {
193192

194193
$_POST = stripslashes_deep( $_POST );
195194

196195
update_option( EUCookieLaw3::OPT_SCRIPT, $_POST[ 'banner' ] );
197196
update_option( EUCookieLaw3::OPT_STYLE, $_POST[ 'style' ] );
198-
update_option( EUCookieLaw3::OPT_REGISTER_CONSENT, isset($_POST[ 'consent' ]) );
197+
update_option( EUCookieLaw3::OPT_REGISTER_CONSENT, isset( $_POST[ 'consent' ] ) );
199198
}
200-
$script = get_option( EUCookieLaw3::OPT_SCRIPT, '' );
199+
$script = get_option( EUCookieLaw3::OPT_SCRIPT, '' );
201200
$consent = get_option( EUCookieLaw3::OPT_REGISTER_CONSENT, false );
202-
$style = get_option( EUCookieLaw3::OPT_STYLE, false );
201+
$style = get_option( EUCookieLaw3::OPT_STYLE, false );
203202

204-
$settings = array(
205-
'codeEditor' => wp_enqueue_code_editor( array( 'mode' => 'text/html' ) ),
206-
);
203+
$settings = [
204+
'codeEditor' => wp_enqueue_code_editor( [ 'mode' => 'text/html' ] ),
205+
];
207206
wp_enqueue_script( 'wp-theme-plugin-editor' );
208207

209208
?>
210-
<h3><?=__("What the hell?!?!", EUCookieLaw3::LANG_DOMAIN) ?></h3>
209+
<h3><?= __( "What the hell?!?!", EUCookieLaw3::LANG_DOMAIN ) ?></h3>
211210
<p>
212-
<strong><?=__("Where are all EUCookieLaw settings???", EUCookieLaw3::LANG_DOMAIN)?></strong><br />
213-
<?=__("Don't worry, nowdays all is more simple than in the past! Now you can use the <a href=\"https://diegolamonica.info/tools/eucookielaw/builder/\">online Configuration Builder</a> to produce the right configuration for your site!", EUCookieLaw3::LANG_DOMAIN)?>
211+
<strong><?= __( "Where are all EUCookieLaw settings???", EUCookieLaw3::LANG_DOMAIN ) ?></strong><br/>
212+
<?= __( "Don't worry, nowdays all is more simple than in the past! Now you can use the <a href=\"https://diegolamonica.info/tools/eucookielaw/builder/\">online Configuration Builder</a> to produce the right configuration for your site!", EUCookieLaw3::LANG_DOMAIN ) ?>
214213
</p>
215214
<p></p>
216215

217-
<label for="code-editor"><?php _e( "EUCookieLaw Banner source code", EUCookieLaw3::LANG_DOMAIN ); ?></label></th>
216+
<label
217+
for="code-editor"><?php _e( "EUCookieLaw Banner source code", EUCookieLaw3::LANG_DOMAIN ); ?></label></th>
218218

219219
<textarea id="code-editor" name="banner" cols="30" rows="18"
220-
class="large-text"><?=htmlspecialchars($script)?></textarea>
220+
class="large-text"><?= htmlspecialchars( $script ) ?></textarea>
221221
<p class="help">
222-
<?=__( "Paste the code obtained from the builder", EUCookieLaw3::LANG_DOMAIN ); ?>
222+
<?= __( "Paste the code obtained from the builder", EUCookieLaw3::LANG_DOMAIN ); ?>
223223
</p>
224224
<div>
225225
<label>
226-
<input type="checkbox" value="1" name="consent" <?php checked($consent)?>>
227-
<strong><?=__("Register user consent", EUCookieLaw3::LANG_DOMAIN)?></strong>
226+
<input type="checkbox" value="1" name="consent" <?php checked( $consent ) ?>>
227+
<strong><?= __( "Register user consent", EUCookieLaw3::LANG_DOMAIN ) ?></strong>
228228
</label>
229229
<p class="help">
230-
<?=__('Enable this flag if you want that all consents and rejections should be tracked', EUCookieLaw3::LANG_DOMAIN);?>
230+
<?= __( 'Enable this flag if you want that all consents and rejections should be tracked', EUCookieLaw3::LANG_DOMAIN ); ?>
231231
</p>
232232
</div>
233233
<div>
234234
<label>
235-
<?=__("Select banner aspect:", EUCookieLaw3::LANG_DOMAIN); ?>
235+
<?= __( "Select banner aspect:", EUCookieLaw3::LANG_DOMAIN ); ?>
236236
<select name="style">
237-
<option value="" <?php selected($style=='' ) ?>><?= _e( "No decoration" , EUCookieLaw3::LANG_DOMAIN); ?></option>
238-
<option value="bootstrap-like.css" <?php selected($style=='bootstrap-like.css' ) ?>>Bootstrap Like</option>
239-
<option value="darky-miky.css" <?php selected($style=='darky-miky.css' ) ?>>Dark Style</option>
237+
<option
238+
value="" <?php selected( $style == '' ) ?>><?= __( "No decoration", EUCookieLaw3::LANG_DOMAIN ); ?></option>
239+
<option value="bootstrap-like.css" <?php selected( $style == 'bootstrap-like.css' ) ?>>Bootstrap
240+
Like
241+
</option>
242+
<option value="darky-miky.css" <?php selected( $style == 'darky-miky.css' ) ?>>Dark Style</option>
240243
</select>
241244
<p class="help">
242-
<?=sprintf(
243-
__("You can set a default style or you should define the rules for the Banner following the <a href=\"%s\">design guideguide documentation</a>", EUCookieLaw3::LANG_DOMAIN), "https://github.com/diegolamonica/EUCookieLaw3-themes"); ?>
245+
<?= sprintf(
246+
__( "You can set a default style or you should define the rules for the Banner following the <a href=\"%s\">design guideguide documentation</a>", EUCookieLaw3::LANG_DOMAIN ), "https://github.com/diegolamonica/EUCookieLaw3-themes" ); ?>
244247
</p>
245248
</label>
246249
</div>
@@ -249,8 +252,8 @@ class="large-text"><?=htmlspecialchars($script)?></textarea>
249252

250253
public function tools() {
251254
?>
252-
<h1><?=__("Useful resource for good people!", EUCookieLaw3::LANG_DOMAIN);?></h1>
253-
<?
255+
<h1><?= __( "Useful resource for good people!", EUCookieLaw3::LANG_DOMAIN ); ?></h1>
256+
<?php
254257

255258
$response = wp_remote_get( "https://diegolamonica.info/tools/eucookielaw/tools.json" );
256259

@@ -264,31 +267,31 @@ public function tools() {
264267

265268
if ( ! $toolsList ) {
266269
_e( "I am not able to retrieve useful resource list at the moment... please try later", EUCookieLaw3::LANG_DOMAIN );
267-
}else {
270+
} else {
268271

269272
?>
270273

271274
<p>
272-
<?=__("The following resources are not directly related to this plugin.", EUCookieLaw3::LANG_DOMAIN) ?>
275+
<?= __( "The following resources are not directly related to this plugin.", EUCookieLaw3::LANG_DOMAIN ) ?>
273276
</p>
274277
<p>
275-
<?=sprintf(
278+
<?= sprintf(
276279

277-
__("If you discover some useful resources online related to CookieLaw and GDPR and you want to share with all, " .
278-
"let me knwo at <a href=\"mailto:%s\">%1\$s</a>.", EUCookieLaw3::LANG_DOMAIN),
279-
'diego.lamonica@gmail.com');
280-
?>
280+
__( "If you discover some useful resources online related to CookieLaw and GDPR and you want to share with all, " .
281+
"let me knwo at <a href=\"mailto:%s\">%1\$s</a>.", EUCookieLaw3::LANG_DOMAIN ),
282+
'diego.lamonica@gmail.com' );
283+
?>
281284
</p>
282285

283286
<ul class="tool-list">
284287
<?php
285288
foreach ( $toolsList as $item ) {
286-
if( empty($item->icon ) ){
289+
if ( empty( $item->icon ) ) {
287290
$item->icon = plugins_url( '/img/logo.png', __FILE__ );
288291
}
289292
?>
290293
<li class="tool-item">
291-
<img class="tool-icon" src="<?=$item->icon?>" alt="" />
294+
<img class="tool-icon" src="<?= $item->icon ?>" alt=""/>
292295
<div class="tool-info">
293296
<h2 class="tool-title"><?= $item->title ?></h2>
294297
<p class="tool-description"><?= $item->description ?></p>
@@ -351,7 +354,7 @@ public function setAdminColumns( $cols ) {
351354
$cols = [
352355
'cb' => '<input type="checkbox" />',
353356
EUCookieLaw3::MD_CONSENTID => __( 'Consent Identifier', EUCookieLaw3::LANG_DOMAIN ),
354-
EUCookieLaw3::MD_SERVICE => __( 'Service', EUCookieLaw3::LANG_DOMAIN ),
357+
EUCookieLaw3::MD_SERVICE => __( 'Service', EUCookieLaw3::LANG_DOMAIN ),
355358
EUCookieLaw3::MD_STATUS => __( 'Consent status', EUCookieLaw3::LANG_DOMAIN ),
356359
EUCookieLaw3::MD_WHEN => __( 'Since', EUCookieLaw3::LANG_DOMAIN ),
357360
EUCookieLaw3::MD_USER_ADDRESS => __( 'IP Address', EUCookieLaw3::LANG_DOMAIN ),
@@ -383,13 +386,16 @@ public function showAdminColumns( $col ) {
383386

384387

385388
public function registerStartupScripts() {
386-
wp_enqueue_script('cm_xml');
387-
wp_enqueue_script('cm_javascript');
388-
wp_enqueue_script('cm_css');
389-
wp_enqueue_script( __CLASS__, plugins_url( '/scripts/backend.js', __FILE__ ), [ 'jquery','wp-codemirror' ], EUCookieLaw3::VERSION, false );
390-
wp_enqueue_style(__CLASS__, plugins_url( '/css/backend.css', __FILE__ ), [], EUCookieLaw3::VERSION, false );
391-
wp_enqueue_style('codemirror');
392-
wp_enqueue_style('cm_blackboard');
389+
wp_enqueue_script( 'cm_xml' );
390+
wp_enqueue_script( 'cm_javascript' );
391+
wp_enqueue_script( 'cm_css' );
392+
wp_enqueue_script( __CLASS__, plugins_url( '/scripts/backend.js', __FILE__ ), [
393+
'jquery',
394+
'wp-codemirror',
395+
], EUCookieLaw3::VERSION, false );
396+
wp_enqueue_style( __CLASS__, plugins_url( '/css/backend.css', __FILE__ ), [], EUCookieLaw3::VERSION, false );
397+
wp_enqueue_style( 'codemirror' );
398+
wp_enqueue_style( 'cm_blackboard' );
393399
}
394400

395401
public function saveEUCookieLawStatus( $postId ) {

custom-post.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class toSendItCustomPost {
77

88
private static $langDomain = 'default';
99

10-
public function setLangDomain($domain){
10+
public function setLangDomain( $domain ) {
1111
self::$langDomain = $domain;
1212
}
1313

@@ -43,8 +43,8 @@ public function register( $postName, $slug, $plurarArticle, $singularName, $plur
4343

4444
$instrSingular = strtolower( $singularName );
4545
$instrPlural = strtolower( $pluralName );
46-
$postSettings = [
47-
'labels' => [
46+
$postSettings = [
47+
'labels' => [
4848
'name' => __( $pluralName, $langDomain ),
4949
'singular_name' => __( $singularName, $langDomain ),
5050
'all_items' => __( "All $plurarArticle$instrPlural", $langDomain ),
@@ -55,17 +55,17 @@ public function register( $postName, $slug, $plurarArticle, $singularName, $plur
5555
'not_found' => __( "$singularName not found", $langDomain ),
5656
'not_found_in_trash' => __( "No $instrPlural in trash", $langDomain ),
5757
],
58-
'public' => true,
59-
'publicly_queryable' => $public,
60-
'has_archive' => true,
61-
'rewrite' => [ 'slug' => $slug ],
62-
'hierarchical' => false,
63-
'supports' => $supports,
58+
'public' => true,
59+
'publicly_queryable' => $public,
60+
'has_archive' => true,
61+
'rewrite' => [ 'slug' => $slug ],
62+
'hierarchical' => false,
63+
'supports' => $supports,
6464
'register_meta_box_cb' => $metaBoxCallBack,
6565
];
6666

6767

68-
$postSettings = array_merge( $postSettings, $capabilities);
68+
$postSettings = array_merge( $postSettings, $capabilities );
6969

7070
register_post_type(
7171
$postName,
@@ -241,8 +241,8 @@ public function drawField( $field, $meta, $displayInTableForm ) {
241241

242242
if ( ! isset( $field[ 'options' ] ) ) {
243243
$fieldOutput = '<input type="checkbox" name="' . $field[ 'id' ] . '" id="' . $field[ 'id' ] . '"' . ( $meta ? ' checked="checked"' : '' ) . ' />';
244-
if($requiresLabel){
245-
$fieldOutput = '<label>' . $fieldOutput . ' ' . $field['name'] . '</label>';
244+
if ( $requiresLabel ) {
245+
$fieldOutput = '<label>' . $fieldOutput . ' ' . $field[ 'name' ] . '</label>';
246246
$requiresLabel = false;
247247
}
248248
} else {
@@ -288,7 +288,7 @@ public function drawField( $field, $meta, $displayInTableForm ) {
288288
break;
289289
}
290290

291-
if ( !empty($field[ 'desc' ]) ) {
291+
if ( ! empty( $field[ 'desc' ] ) ) {
292292
$fieldOutput .= '<p class="help">' . $field[ 'desc' ] . '</p>';
293293
}
294294

eucookielaw.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
class EUCookieLaw3 {
4-
const VERSION = '20180520';
4+
const VERSION = '20180523';
55
const POST_NAME = 'EUCookieLaw';
66
const POST_SLUG = 'eucookielaw';
77
const LANG_DOMAIN = 'EUCookieLaw3';

frontend.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ public function includeEUCookieLawScript() {
3636

3737
$id = get_the_ID();
3838

39-
$status = EUCookieLaw3::get( EUCookieLaw3::MD_DISABLED,'','',$id );
39+
$status = EUCookieLaw3::get( EUCookieLaw3::MD_DISABLED, '', '', $id );
4040

4141

42-
if ( $status !== '1') {
42+
if ( $status !== '1' ) {
4343
$value = get_option( EUCookieLaw3::OPT_SCRIPT, '<!-- not found -->' );
4444
echo $value;
4545
}
4646
}
4747

4848
public function init() {
4949

50-
$style = get_option( EUCookieLaw3::OPT_STYLE, '');
51-
if( $style !== '' ){
50+
$style = get_option( EUCookieLaw3::OPT_STYLE, '' );
51+
if ( $style !== '' ) {
5252
wp_register_style( __CLASS__, plugins_url( 'css/' . $style, __FILE__ ) );
5353
}
5454

@@ -88,26 +88,26 @@ public function getConsents() {
8888
$guid = $_POST[ 'guid' ];
8989

9090
$posts = get_posts( [
91-
'post_type' => EUCookieLaw3::POST_SLUG,
92-
'post_status' => 'draft',
93-
'meta_key' => EUCookieLaw3::MD_CONSENTID,
94-
'meta_value' => $guid,
95-
'posts_per_page' => -1
91+
'post_type' => EUCookieLaw3::POST_SLUG,
92+
'post_status' => 'draft',
93+
'meta_key' => EUCookieLaw3::MD_CONSENTID,
94+
'meta_value' => $guid,
95+
'posts_per_page' => - 1,
9696
] );
9797

9898
$exportedKeys = [
9999
EUCookieLaw3::MD_SERVICE,
100100
EUCookieLaw3::MD_STATUS,
101101
EUCookieLaw3::MD_WHEN,
102-
EUCookieLaw3::MD_SERVICE
102+
EUCookieLaw3::MD_SERVICE,
103103
];
104104

105105
$records = [];
106-
foreach($posts as $post ){
106+
foreach ( $posts as $post ) {
107107
$record = [];
108-
foreach($exportedKeys as $exportedKey){
108+
foreach ( $exportedKeys as $exportedKey ) {
109109

110-
$record[ $exportedKey ] = EUCookieLaw3::get($exportedKey,'','', $post->ID);
110+
$record[ $exportedKey ] = EUCookieLaw3::get( $exportedKey, '', '', $post->ID );
111111

112112
}
113113

0 commit comments

Comments
 (0)