Skip to content

Commit 33f2a71

Browse files
committed
v1.0.8
Fix all checkbox issue
1 parent bd0554b commit 33f2a71

9 files changed

Lines changed: 604 additions & 125 deletions

File tree

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# WP Post Hide
2+
3+
Control the visibility of post type items like pages, posts and custom post type. Hidden in a specific part. But another part still visible.
4+
5+
## Requirements
6+
7+
* WordPress 5.7 or newer
8+
* WooCommerce 6.9 or newer
9+
* PHP 7.4 or newer
10+
11+
## Installation
12+
13+
1. [Download and extract a .zip archive of the plugin](https://downloads.wordpress.org/plugin/wp-post-hide.zip) (or clone this repository) into your site's plugins directory (`wp-content/plugins/` by default).
14+
2. Activate the plugin through the Plugins screen in WP Admin.
15+
16+
### Control the visibility of a post in various views:
17+
<dl>
18+
<dd>The Front Page (Homepage, depending on your theme, this may not be relevant)</dd>
19+
<dd>The Category Page (listing the posts belonging to a category)</dd>
20+
<dd>The Search Results.</dd>
21+
</dl>
22+
23+
### Control the visibility of a page in various views:
24+
<dl>
25+
<dd>Hide a page on the front page (homepage) only.</dd>
26+
<dd>Hide a page everywhere in the blog (hiding the page in the search results is optional)</dd>
27+
</dl>
28+
29+
### Free Features:
30+
<dl>
31+
<dd>Post hide from the front page</dd>
32+
<dd>Post hide from category page</dd>
33+
<dd>Post hide from a search result</dd>
34+
<dd>The page is hidden from the front page</dd>
35+
<dd>The page is hidden everywhere</dd>
36+
</dl>
37+
38+
### Premium Features:
39+
<dl>
40+
<dd>Post hidden form tag page</dd>
41+
<dd>Post hidden form Author page</dd>
42+
<dd>Post hidden form Archive page</dd>
43+
<dd>Post hidden form recent posts</dd>
44+
</dl>
45+
46+
### Premium link
47+
<dl>
48+
<dd><a href="https://codecanyon.net/item/wordpress-hide-post/24141817">WP Post hide</a></dd>
49+
</dl>
50+
51+
### Frequently Asked Questions
52+
<dl>
53+
<dd>How to install this plugin?</dd>
54+
<dd>Upload the wp-post-hide folder to the /wp-content/plugins/ directory Activate the plugin through the Plugins menu in WordPress That's it! Now whenever you edit a post/page or create a new one, you will see a small panel on the bottom right of the screen that shows the applicable options.</dd>
55+
<dd>What does this plugin do?</dd>
56+
<dd>It enables you to create posts/pages that can be hidden (temporarily or permanently) from the homepage, category and search. The post/page will remain accessible normally through other means, such as permalinks, archives, etc… and thus will remain visible to search engines.</dd>
57+
</dl>

assets/css/xswpph-style.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@
3636
margin: 0px;
3737
padding-bottom: 0px;
3838
}
39+
#xswpph_name,#xswpph_email{
40+
width: 335px;
41+
}
42+
.xs-send-email-notice{
43+
display: none;
44+
}
45+
.xs-notice-dismiss{
46+
display:none;
47+
}
48+
.xswpph-send-mail{
49+
font-size: 15px !important;
50+
font-family: bold;
51+
padding: 2px 15px !important;
52+
}
53+
.xswpph_is_active{
54+
display:inline-block;
55+
visibility:visible;
56+
opacity:1
57+
}
58+
.xswpph-top-margin{
59+
margin-top: 20px !important;
60+
}
61+
.xswpph-mail-spinner{
62+
margin-top: 38px ;
63+
}
64+
.error{
65+
outline: 1px solid red;
66+
}
67+
.input-group{
68+
display: inline-flex;
69+
}
3970
@media (max-width: 425px){
4071
.xswpph-col {
4172
width: 400px;

assets/js/xswpph-script.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,101 @@ jQuery(document).ready(function($) {
3434
$('.xswpph-enables').hide();
3535
}
3636
});
37+
$('#xswpph_name , #xswpph_email , #xswpph_message').on('change',function(e){
38+
if(!$(this).val()){
39+
$(this).addClass("error");
40+
}else{
41+
$(this).removeClass("error");
42+
}
43+
});
44+
$('.xswpph_support_form').on('submit' , function(e){
45+
e.preventDefault();
46+
$('.xs-send-email-notice').hide();
47+
$('.xswpph-mail-spinner').addClass('xswpph_is_active');
48+
$('#xswpph_name').removeClass("error");
49+
$('#xswpph_email').removeClass("error");
50+
$('#xswpph_message').removeClass("error");
51+
52+
$.ajax({
53+
url:ajaxurl,
54+
type:'post',
55+
data:{'action':'xswpph_send_mail','data':$(this).serialize()},
56+
beforeSend: function(){
57+
if(!$('#xswpph_name').val()){
58+
$('#xswpph_name').addClass("error");
59+
$('.xs-send-email-notice').removeClass('notice-success');
60+
$('.xs-send-email-notice').addClass('notice');
61+
$('.xs-send-email-notice').addClass('error');
62+
$('.xs-send-email-notice').addClass('is-dismissible');
63+
$('.xs-send-email-notice p').html('Please fill all the fields');
64+
$('.xs-send-email-notice').show();
65+
$('.xs-notice-dismiss').show();
66+
window.scrollTo(0,0);
67+
$('.xswpph-mail-spinner').removeClass('xswpph_is_active');
68+
return false;
69+
}
70+
if(!$('#xswpph_email').val()){
71+
$('#xswpph_email').addClass("error");
72+
$('.xs-send-email-notice').removeClass('notice-success');
73+
$('.xs-send-email-notice').addClass('notice');
74+
$('.xs-send-email-notice').addClass('error');
75+
$('.xs-send-email-notice').addClass('is-dismissible');
76+
$('.xs-send-email-notice p').html('Please fill all the fields');
77+
$('.xs-send-email-notice').show();
78+
$('.xs-notice-dismiss').show();
79+
window.scrollTo(0,0);
80+
$('.xswpph-mail-spinner').removeClass('xswpph_is_active');
81+
return false;
82+
}
83+
if(!$('#xswpph_message').val()){
84+
$('#xswpph_message').addClass("error");
85+
$('.xs-send-email-notice').removeClass('notice-success');
86+
$('.xs-send-email-notice').addClass('notice');
87+
$('.xs-send-email-notice').addClass('error');
88+
$('.xs-send-email-notice').addClass('is-dismissible');
89+
$('.xs-send-email-notice p').html('Please fill all the fields');
90+
$('.xs-send-email-notice').show();
91+
$('.xs-notice-dismiss').show();
92+
window.scrollTo(0,0);
93+
$('.xswpph-mail-spinner').removeClass('xswpph_is_active');
94+
return false;
95+
}
96+
$(".xswpph_support_form :input").prop("disabled", true);
97+
$("#xswpph_message").prop("disabled", true);
98+
$('.xswpph-send-mail').prop('disabled',true);
99+
},
100+
success: function(res){
101+
$('.xs-send-email-notice').find('.xs-notice-dismiss').show();
102+
$('.xswpph-send-mail').prop('disabled',false);
103+
$(".xswpph_support_form :input").prop("disabled", false);
104+
$("#xswpph_message").prop("disabled", false);
105+
if(res.status == true){
106+
$('.xs-send-email-notice').removeClass('error');
107+
$('.xs-send-email-notice').addClass('notice');
108+
$('.xs-send-email-notice').addClass('notice-success');
109+
$('.xs-send-email-notice').addClass('is-dismissible');
110+
$('.xs-send-email-notice p').html('Successfully sent');
111+
$('.xs-send-email-notice').show();
112+
$('.xs-notice-dismiss').show();
113+
$('.xswpph_support_form')[0].reset();
114+
}else{
115+
$('.xs-send-email-notice').removeClass('notice-success');
116+
$('.xs-send-email-notice').addClass('notice');
117+
$('.xs-send-email-notice').addClass('error');
118+
$('.xs-send-email-notice').addClass('is-dismissible');
119+
$('.xs-send-email-notice p').html('Sent Failed');
120+
$('.xs-send-email-notice').show();
121+
$('.xs-notice-dismiss').show();
122+
}
123+
$('.xswpph-mail-spinner').removeClass('xswpph_is_active');
124+
}
125+
126+
});
127+
});
128+
$('.xs-notice-dismiss').on('click',function(e){
129+
e.preventDefault();
130+
$(this).parent().hide();
131+
$(this).hide();
132+
});
37133

38134
});

includes/classes/class-xswpph-init.php

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ public static function xswpph_admin_menu() {
2626
'dashicons-admin-settings',
2727
40
2828
);
29+
add_submenu_page(
30+
'xswpph_page',
31+
esc_html__( 'Support' , 'xswpph-domain' ),
32+
esc_html__( 'Support' , 'xswpph-domain' ),
33+
'manage_options',
34+
'xswpph_support',
35+
'xswpph_support',
36+
);
2937
}
3038

3139
/**
@@ -34,13 +42,13 @@ public static function xswpph_admin_menu() {
3442
* @return NULL
3543
*/
3644
public static function xswpph_load_css_js() {
37-
if(isset($_GET['page']) && $_GET['page'] == 'xswpph_page'){
45+
wp_register_script( 'xswpph-scripts' , plugins_url( "wp-post-hide/assets/js/xswpph-script.js" ) ) ;
46+
wp_enqueue_script( 'jquery' );
47+
if(isset($_GET['page']) && ($_GET['page'] == 'xswpph_page' || $_GET['page'] == 'xswpph_support') ){
3848
wp_register_style( 'xswpph-styles' , plugins_url( "wp-post-hide/assets/css/xswpph-style.css" ) ) ;
39-
wp_register_script( 'xswpph-scripts' , plugins_url( "wp-post-hide/assets/js/xswpph-script.js" ) ) ;
40-
wp_enqueue_script( 'jquery' );
4149
wp_enqueue_style( 'xswpph-styles' );
42-
wp_enqueue_script('xswpph-scripts');
4350
}
51+
wp_enqueue_script('xswpph-scripts');
4452
}
4553

4654
/**
@@ -130,34 +138,29 @@ public static function xswpph_save_meta_data( $post_id ,$post) {
130138
*/
131139
public static function xswpph_hidden_posts_pages( $query ) {
132140

133-
if( !is_admin() ) {
134-
135-
if( ( function_exists( 'is_home' ) && is_home() ) || ( function_exists( 'is_front_page' ) && is_front_page() ) ) {
141+
if( !is_admin() && $query->is_main_query() ) {
142+
143+
$xswpph_pages = self::xswpph_database_query( "_xswpph_always","Always" ) ;
144+
$xswpph_seapages = self::xswpph_database_query( "_xswpph_keep_search" , "_xswpph_keep_search" );
145+
if($query->is_home() || $query->is_front_page() ) {
136146
$xswpph_posts = self::xswpph_database_query( "_xswpph_front_page" , "Front Page" );
137-
$xswpph_pages = self::xswpph_database_query( "_xswpph_always","Always" ) ;
138147
$wphp_hidden = array_merge( $xswpph_posts , $xswpph_pages );
139-
140-
$xswpph_pages = self::xswpph_database_query( "_xswpph_keep_search" , "_xswpph_keep_search" );
141-
$wphp_hidden = array_merge( $wphp_hidden , $xswpph_pages );
142-
148+
$wphp_hidden = array_merge( $wphp_hidden , $xswpph_seapages );
143149
$query->set('post__not_in', $wphp_hidden);
144150
}
145151

146152
if ( $query->is_search() ) {
147153
$xswpph_posts = self::xswpph_database_query( "_xswpph_search" , "Search Results" );
148-
$xswpph_pages = self::xswpph_database_query( "_xswpph_always" , "Always" ) ;
149154
$wphp_hidden = array_merge( $xswpph_posts, $xswpph_pages );
150-
$query->set('post__not_in', $wphp_hidden);
155+
if(get_search_query()){
156+
$query->set('post__not_in', $wphp_hidden);
157+
}
151158
}
152159

153160
if ( $query->is_category() ) {
154161
$xswpph_posts = self::xswpph_database_query( "_xswpph_category_page" , "Category Pages");
155-
$xswpph_pages = self::xswpph_database_query( "_xswpph_always","Always" ) ;
156162
$wphp_hidden = array_merge( $xswpph_posts , $xswpph_pages );
157-
158-
$xswpph_pages = self::xswpph_database_query( "_xswpph_keep_search" , "_xswpph_keep_search" );
159-
$wphp_hidden = array_merge( $wphp_hidden , $xswpph_pages );
160-
163+
$wphp_hidden = array_merge( $wphp_hidden ,$xswpph_seapages);
161164
$query->set('post__not_in', $wphp_hidden);
162165
}
163166
}
@@ -179,6 +182,56 @@ public static function xswpph_database_query( $meta_key , $meta_value ) {
179182
}
180183
return $post_ids;
181184
}
185+
186+
public static function xswpph_send_mail(){
187+
$data = array();
188+
parse_str($_POST['data'], $data);
189+
$data['plugin_name'] = 'WP Post hide';
190+
$data['version'] = 'lite';
191+
$data['website'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST'];
192+
$to = 'xfinitysoft@gmail.com';
193+
switch ($data['type']) {
194+
case 'report':
195+
$subject = 'Report a bug';
196+
break;
197+
case 'hire':
198+
$subject = 'Hire us to customize/develope Plugin/Theme or WordPress projects';
199+
break;
200+
201+
default:
202+
$subject = 'Request a Feature';
203+
break;
204+
}
205+
206+
$body = '<html><body><table>';
207+
$body .='<tbody>';
208+
$body .='<tr><th>User Name</th><td>'.$data['xswpph_name'].'</td></tr>';
209+
$body .='<tr><th>User email</th><td>'.$data['xswpph_email'].'</td></tr>';
210+
$body .='<tr><th>Plugin Name</th><td>'.$data['plugin_name'].'</td></tr>';
211+
$body .='<tr><th>Version</th><td>'.$data['version'].'</td></tr>';
212+
$body .='<tr><th>Website</th><td><a href="'.$data['website'].'">'.$data['website'].'</a></td></tr>';
213+
$body .='<tr><th>Message</th><td>'.$data['xswpph_message'].'</td></tr>';
214+
$body .='</tbody>';
215+
$body .='</table></body></html>';
216+
$headers = array('Content-Type: text/html; charset=UTF-8');
217+
$params ="name=".$data['xswpph_name'];
218+
$params.="&email=".$data['xswpph_email'];
219+
$params.="&site=".$data['website'];
220+
$params.="&version=".$data['version'];
221+
$params.="&plugin_name=".$data['plugin_name'];
222+
$params.="&type=".$data['type'];
223+
$params.="&message=".$data['xswpph_message'];
224+
$sever_response = wp_remote_post("https://xfinitysoft.com/wp-json/plugin/v1/quote/save/?".$params);
225+
$se_api_response = json_decode( wp_remote_retrieve_body( $sever_response ), true );
226+
227+
if($se_api_response['status']){
228+
$mail = wp_mail( $to, $subject, $body, $headers );
229+
wp_send_json(array('status'=>true));
230+
}else{
231+
wp_send_json(array('status'=>false));
232+
}
233+
wp_die();
234+
}
182235

183236
}
184237
?>

includes/classes/class-xswpph-main.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,19 @@ function xswpph_init_hooks() {
6363
add_action( 'add_meta_boxes', array( 'XSWPPH_Init' , 'xswpph_add_meta_box' ) );
6464
add_action( 'save_post' , array( 'XSWPPH_Init' , 'xswpph_save_meta_data'), 10,3 );
6565
add_action( 'pre_get_posts' , array( 'XSWPPH_Init' , 'xswpph_hidden_posts_pages') );
66+
add_action( 'wp_ajax_xswpph_send_mail' ,array('XSWPPH_Init','xswpph_send_mail'));
6667
}
6768

6869
/**
6970
* Includes the files
7071
*/
7172
function xswpph_includes() {
72-
73-
include_once XSWPPH_ABSPATH . '/includes/classes/class-xswpph-init.php';
74-
include_once XSWPPH_ABSPATH . '/templates/xswpph-page.php';
7573
include_once XSWPPH_ABSPATH . '/templates/views/xswpph-metaboxes.php';
7674
include_once XSWPPH_ABSPATH . '/includes/functions/xswpph-functions.php';
75+
include_once XSWPPH_ABSPATH . '/includes/classes/class-xswpph-init.php';
76+
include_once XSWPPH_ABSPATH . '/templates/xswpph-page.php';
77+
include_once XSWPPH_ABSPATH . '/templates/xswpph-support.php';
78+
7779
}
7880

7981
}

0 commit comments

Comments
 (0)