Skip to content

Commit a935c3a

Browse files
committed
Merge branch 'master' into feature/html-template-import
2 parents 5e9c988 + 3edb9ea commit a935c3a

5 files changed

Lines changed: 34 additions & 31 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ script:
1818
- composer install -o --prefer-dist --no-interaction
1919

2020
# Check project with phps
21-
- ./vendor/bin/phpcs -n -p .
21+
- composer run lint

classes/class-cpt-wplf-form.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function register_cpt() {
105105
/**
106106
* Modify post.php permalink html to show notice if form isn't publicly visible.
107107
*/
108-
function modify_permalink_html( $html, $post_id ) {
108+
public function modify_permalink_html( $html, $post_id ) {
109109
$publicly_visible = $this->get_publicly_visible_state( $post_id );
110110

111111
if ( get_post_type( $post_id ) === 'wplf-form' && ! $publicly_visible ) {
@@ -120,7 +120,7 @@ function modify_permalink_html( $html, $post_id ) {
120120
/**
121121
* Disable TinyMCE editor for forms, which are simple HTML things
122122
*/
123-
function disable_tinymce( $default ) {
123+
public function disable_tinymce( $default ) {
124124
global $post;
125125

126126
// only for this cpt
@@ -134,7 +134,7 @@ function disable_tinymce( $default ) {
134134
/**
135135
* Include custom JS and CSS on the edit screen
136136
*/
137-
function admin_post_scripts_cpt( $hook ) {
137+
public function admin_post_scripts_cpt( $hook ) {
138138
global $post;
139139

140140
// make sure we're on the correct view
@@ -160,7 +160,7 @@ function admin_post_scripts_cpt( $hook ) {
160160
/**
161161
* Pre-populate form editor with default content
162162
*/
163-
function default_content_cpt( $content ) {
163+
public function default_content_cpt( $content ) {
164164
global $pagenow;
165165

166166
// only on post.php screen
@@ -211,7 +211,7 @@ function remove_row_actions( $actions, $post ) {
211211
/**
212212
* Custom columns in edit.php for Forms
213213
*/
214-
function custom_columns_cpt( $columns ) {
214+
public function custom_columns_cpt( $columns ) {
215215
$new_columns = array(
216216
'cb' => $columns['cb'],
217217
'title' => $columns['title'],
@@ -226,7 +226,7 @@ function custom_columns_cpt( $columns ) {
226226
/**
227227
* Custom column display for Form CPT in edit.php
228228
*/
229-
function custom_columns_display_cpt( $column, $post_id ) {
229+
public function custom_columns_display_cpt( $column, $post_id ) {
230230
if ( 'shortcode' === $column ) {
231231
?>
232232
<input type="text" class="code" value='[libre-form id="<?php echo intval( $post_id ); ?>"]' readonly>
@@ -253,7 +253,7 @@ function custom_columns_display_cpt( $column, $post_id ) {
253253
/**
254254
* Add meta box to show fields in form
255255
*/
256-
function add_meta_boxes_cpt() {
256+
public function add_meta_boxes_cpt() {
257257
// Shortcode meta box
258258
add_meta_box(
259259
'wplf-shortcode',
@@ -307,7 +307,7 @@ function add_meta_boxes_cpt() {
307307
/**
308308
* Meta box callback for shortcode meta box
309309
*/
310-
function metabox_shortcode( $post ) {
310+
public function metabox_shortcode( $post ) {
311311
?>
312312
<p><input type="text" class="code" value='[libre-form id="<?php echo esc_attr( $post->ID ); ?>"]' readonly></p>
313313
<?php
@@ -339,7 +339,7 @@ function metabox_thank_you( $post ) {
339339
/**
340340
* Meta box callback for form fields meta box
341341
*/
342-
function metabox_form_fields() {
342+
public function metabox_form_fields() {
343343
?>
344344
<p><?php esc_html_e( 'Fields marked with * are required', 'wp-libre-form' ); ?></p>
345345
<div class="wplf-form-field-container">
@@ -353,7 +353,7 @@ function metabox_form_fields() {
353353
/**
354354
* Meta box callback for submit email meta box
355355
*/
356-
function metabox_submit_email( $post ) {
356+
public function metabox_submit_email( $post ) {
357357
// get post meta
358358
$meta = get_post_meta( $post->ID );
359359
$email_enabled = isset( $meta['_wplf_email_copy_enabled'] ) ? $meta['_wplf_email_copy_enabled'][0] : true;
@@ -444,7 +444,7 @@ function metabox_submit_email( $post ) {
444444
/**
445445
* Meta box callback for submission title format
446446
*/
447-
function meta_box_title_format( $post ) {
447+
public function meta_box_title_format( $post ) {
448448
// get post meta
449449
$meta = get_post_meta( $post->ID );
450450
$default = '%name% <%email%>'; // default submission title format
@@ -602,7 +602,7 @@ protected function maybe_persist_override_template( $template, $form_id, $force
602602
/**
603603
* Handles saving our post meta
604604
*/
605-
function save_cpt( $post_id ) {
605+
public function save_cpt( $post_id ) {
606606
// verify nonce
607607
if ( ! isset( $_POST['wplf_form_meta_nonce'] ) ) {
608608
return;
@@ -716,15 +716,15 @@ function save_cpt( $post_id ) {
716716
*
717717
* We apply <form> via the shortcode, you can't have nested forms anyway
718718
*/
719-
function strip_form_tags( $content ) {
719+
public function strip_form_tags( $content ) {
720720
return preg_replace( '/<\/?form.*>/i', '', $content );
721721
}
722722

723723

724724
/**
725725
* The function we display the form with
726726
*/
727-
function wplf_form( $id, $content = '', $xclass = '', $attributes = [] ) {
727+
public function wplf_form( $id, $content = '', $xclass = '', $attributes = [] ) {
728728
global $post;
729729
$preview = ! empty( $_GET['preview'] ) ? $_GET['preview'] : false;
730730

@@ -803,7 +803,7 @@ class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
803803
/**
804804
* Enqueue the front end JS
805805
*/
806-
function maybe_enqueue_frontend_script() {
806+
public function maybe_enqueue_frontend_script() {
807807
global $post;
808808

809809
// register the script, but only enqueue it if the current post contains a form in it
@@ -827,7 +827,7 @@ function maybe_enqueue_frontend_script() {
827827
/**
828828
* Shortcode for displaying a Form
829829
*/
830-
function shortcode( $shortcode_atts, $content = null ) {
830+
public function shortcode( $shortcode_atts, $content = null ) {
831831
$attributes = shortcode_atts( array(
832832
'id' => null,
833833
'xclass' => '',
@@ -849,7 +849,7 @@ function shortcode( $shortcode_atts, $content = null ) {
849849
/**
850850
* Use the shortcode for previewing forms
851851
*/
852-
function use_shortcode_for_preview( $content ) {
852+
public function use_shortcode_for_preview( $content ) {
853853
global $post;
854854
if ( ! isset( $post->post_type ) || $post->post_type !== 'wplf-form' ) {
855855
return $content;
@@ -861,7 +861,7 @@ function use_shortcode_for_preview( $content ) {
861861
* Set and show 404 page for visitors trying to see single form.
862862
* And yes, it is a global $post. That's right.
863863
*/
864-
function maybe_set_404_for_single_form() {
864+
public function maybe_set_404_for_single_form() {
865865
global $post;
866866

867867
if ( ! is_singular( 'wplf-form' ) ) {
@@ -882,14 +882,14 @@ function maybe_set_404_for_single_form() {
882882
/**
883883
* Wrapper function to check if form is publicly visible.
884884
*/
885-
function get_publicly_visible_state( $id ) {
885+
public function get_publicly_visible_state( $id ) {
886886
return apply_filters( 'wplf-form-publicly-visible', false, $id );
887887
}
888888

889889
/**
890890
* A very simple uglify. Just removes line breaks from html
891891
*/
892-
function minify_html( $html ) {
892+
public function minify_html( $html ) {
893893
return str_replace( array( "\n", "\r" ), ' ', $html );
894894
}
895895
}

classes/class-cpt-wplf-submission.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function register_cpt() {
7878
/**
7979
* Custom column display for Submission CPT in edit.php
8080
*/
81-
function custom_columns_display_cpt( $column, $post_id ) {
81+
public function custom_columns_display_cpt( $column, $post_id ) {
8282
if ( 'referrer' === $column ) {
8383
if ( $referrer = get_post_meta( $post_id, 'referrer', true ) ) {
8484
echo '<a href="' . esc_url_raw( $referrer ) . '">' . esc_url( $referrer ) . '</a>';
@@ -97,7 +97,7 @@ function custom_columns_display_cpt( $column, $post_id ) {
9797
/**
9898
* Custom columns in edit.php for Forms
9999
*/
100-
function custom_columns_cpt( $columns ) {
100+
public function custom_columns_cpt( $columns ) {
101101
$new_columns = array(
102102
'cb' => $columns['cb'],
103103
'title' => $columns['title'],
@@ -111,7 +111,7 @@ function custom_columns_cpt( $columns ) {
111111
/**
112112
* Show a form filter in the edit.php view
113113
*/
114-
function form_filter_dropdown() {
114+
public function form_filter_dropdown() {
115115
global $pagenow;
116116

117117
$allowed = array( 'wplf-submission' ); // show filter on these post types (currently only one?)
@@ -152,7 +152,7 @@ function form_filter_dropdown() {
152152
/**
153153
* Filter by form in the edit.php view
154154
*/
155-
function filter_by_form( $query ) {
155+
public function filter_by_form( $query ) {
156156
global $pagenow;
157157

158158
if ( 'edit.php' !== $pagenow ) {
@@ -171,12 +171,12 @@ function filter_by_form( $query ) {
171171
return $query;
172172
}
173173

174-
function register_wplf_submission_bulk_actions( $bulk_actions ) {
174+
public function register_wplf_submission_bulk_actions( $bulk_actions ) {
175175
$bulk_actions['wplf_resend_copy'] = __( 'Resend email copy', 'wp-libre-form' );
176176
return $bulk_actions;
177177
}
178178

179-
function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
179+
public function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
180180
if ( $doaction !== 'wplf_resend_copy' ) {
181181
return $redirect_to;
182182
}
@@ -192,7 +192,7 @@ function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids
192192
return $redirect_to;
193193
}
194194

195-
function wplf_submission_bulk_action_admin_notice() {
195+
public function wplf_submission_bulk_action_admin_notice() {
196196
if ( ! empty( $_REQUEST['wplf_resent'] ) ) {
197197
$count = intval( $_REQUEST['wplf_resent'] );
198198
printf(
@@ -213,7 +213,7 @@ function wplf_submission_bulk_action_admin_notice() {
213213
/**
214214
* Add meta box to show fields in form
215215
*/
216-
function add_meta_boxes_cpt() {
216+
public function add_meta_boxes_cpt() {
217217
// Shortcode meta box
218218
add_meta_box(
219219
'wplf-shortcode',
@@ -228,7 +228,7 @@ function add_meta_boxes_cpt() {
228228
/**
229229
* The submission metabox callback
230230
*/
231-
function metabox_submission() {
231+
public function metabox_submission() {
232232
global $post;
233233
$postmeta = get_post_meta( $post->ID );
234234
$fields = array_keys( $postmeta );

classes/class-wplf-polylang.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function render_form( $form_content ) {
4242
return $form_content;
4343
}
4444

45-
function save_form( $post_id, $post, $update ) {
45+
public function save_form( $post_id, $post, $update ) {
4646
unset( $post_id, $update ); // not used here so shut up linter!
4747

4848
preg_match_all( $this->regular_expression, $post->post_content, $matches );

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
"require-dev": {
1717
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
1818
"wp-coding-standards/wpcs": "0.12.0"
19+
},
20+
"scripts": {
21+
"lint": "./vendor/bin/phpcs --standard=./phpcs.xml -n -p ."
1922
}
2023
}

0 commit comments

Comments
 (0)