Changeset 3135881
- Timestamp:
- 08/15/2024 04:08:52 AM (20 months ago)
- Location:
- mi13-access-by-link/trunk
- Files:
-
- 2 edited
-
mi13-access-by-link.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mi13-access-by-link/trunk/mi13-access-by-link.php
r3001601 r3135881 1 1 <?php 2 2 /* 3 Plugin Name: mi13-access-by-link 4 Plugin URI: https://wordpress.org/plugins/mi13-access-by-link/ 5 Description: Access to your posts (pending) by link. 6 Version: 1.1 7 Author: mi13 8 9 Copyright 2018-2022 Mihail Nebov (email: mihail_teo@mail.ru) 10 11 This program is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 3 Plugin Name: mi13-access-by-link 4 Plugin URI: https://wordpress.org/plugins/mi13-access-by-link/ 5 Description: Access to your posts (pending) by link. 6 Version: 1.2 7 Author: mi13 8 License: GPL v2 or later 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 24 11 */ 25 12 … … 94 81 function mi13_access_by_link_link($id,$key_on) { 95 82 $key = ''; 96 if ($key_on=='1') {83 if($key_on=='1') { 97 84 $key = get_post_meta($id,'mi13-access-by-link-key',true); 98 if (empty($key)) {85 if(empty($key)) { 99 86 $key = wp_generate_password( 12, false ); 100 87 add_post_meta( $id, 'mi13-access-by-link-key', $key, true ); … … 108 95 function mi13_access_by_link_meta_box_callback($post) { 109 96 $text = ''; 110 if ($post->post_status == 'pending') {97 if($post->post_status == 'pending') { 111 98 $id = $post->ID; 112 99 $key_on = get_option('mi13_access_by_link')['key']; … … 142 129 </main><!-- #main --> 143 130 </div><!-- #primary -->'; 144 $settings['header' ] = isset($settings['header']) ? intval($settings['header']) : 0;145 $settings['footer' ] = isset($settings['footer']) ? intval($settings['footer']) : 0;146 $settings['filters' ] = strip_tags($settings['filters']);147 $settings['html' ] = isset($settings['html']) ? force_balance_tags( $settings['html'] ) : $html;148 $settings['key' ] = isset($settings['key']) ? intval($settings['key']) : 0;131 $settings['header'] = isset($settings['header']) ? intval($settings['header']) : 0; 132 $settings['footer'] = isset($settings['footer']) ? intval($settings['footer']) : 0; 133 $settings['filters'] = wp_strip_all_tags($settings['filters']); 134 $settings['html'] = isset($settings['html']) ? force_balance_tags( $settings['html'] ) : $html; 135 $settings['key'] = isset($settings['key']) ? intval($settings['key']) : 0; 149 136 $settings['publish'] = isset($settings['publish']) ? intval($settings['publish']) : 0; 150 137 return $settings; … … 248 235 $filters = explode(',',$filters); 249 236 foreach ($filters as $filter) { 250 if ( !function_exists($filter) ) mi13_access_by_link_error($filter);237 if( !function_exists($filter) ) wp_admin_notice( $filter. ' - ' . __('This function was not found! Please, edit "filters" field.','mi13-access-by-link'),['type' => 'error']); 251 238 } 252 239 $key_on = $settings['key']; … … 257 244 } 258 245 259 function mi13_access_by_link_error($filter) {260 if (!empty($filter)) echo '<div class="error"><p>' .$filter. ' - ' .__('This function was not found! Please, edit "filters" field.','mi13-access-by-link'). '</p></div>';261 }262 263 add_action('wp_ajax_mi13_access_by_link', 'mi13_access_by_link_ajax');264 add_action('wp_ajax_nopriv_mi13_access_by_link', 'mi13_access_by_link_ajax');265 266 246 function mi13_access_by_link_ajax() { 267 247 $settings = get_option('mi13_access_by_link'); 268 248 $key = ''; 269 $id = $_GET['id'];270 if ( isset($_GET['key']) ) $key = $_GET['key'];271 272 if ( $settings['key'] == '1' ) {249 $id = ''; 250 if( isset($_GET['id']) ) $id .= sanitize_text_field($_GET['id']); 251 if( isset($_GET['key']) ) $key .= sanitize_text_field($_GET['key']); 252 if( $settings['key'] == '1' ) { 273 253 $key1 = get_post_meta($id,'mi13-access-by-link-key',true); 274 254 if( empty($key1) ) wp_die('Error: key_not_found'); 275 if( !empty($key1) && ( $key != $key1 ) ) wp_die('Error: invalid key'); 276 } 277 255 if( $key !== $key1 ) wp_die('Error: invalid key'); 256 } 278 257 $post = get_post( $id ); 279 if ($post) {258 if($post) { 280 259 if( ($post->post_status != 'pending') || ($post->post_type != 'post') || (!empty($post->post_password)) ) wp_die('Error: Access denied'); 281 260 $content = $post->post_content; … … 298 277 $html = str_replace('$cat',$cat,$html); 299 278 $html = str_replace('$thumbnail',$thumbnail,$html); 300 if ( $settings['header']=='1' ) get_header();279 if( $settings['header']=='1' ) get_header(); 301 280 echo $html; 302 if ( $settings['footer']=='1' ) get_footer();281 if( $settings['footer']=='1' ) get_footer(); 303 282 } else wp_die('Error: invalid id'); 304 283 wp_die(); 305 284 } 285 add_action('wp_ajax_mi13_access_by_link', 'mi13_access_by_link_ajax'); 286 add_action('wp_ajax_nopriv_mi13_access_by_link', 'mi13_access_by_link_ajax'); 306 287 307 288 ?> -
mi13-access-by-link/trunk/readme.txt
r3001601 r3135881 2 2 Contributors: mi13 3 3 Tags: access by link, privacy link, pending 4 Requires at least: 4.7 5 Tested up to: 6.3.2 6 Stable tag: 1.1 4 Requires at least: 6.4.0 5 Tested up to: 6.6.1 6 Stable tag: 1.2 7 License: GPLv2 or later 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html 7 9 8 Доступ к Вашим постам (на утверждении) по ссылке 10 Доступ к Вашим постам (на утверждении) по ссылке для модераторов. 9 11 10 12 == Description == … … 50 52 * fix bug. 51 53 = 1.1 = 52 * Доработан код. Удален пойск мета в тексте, так как для этого есть фильтры. 54 * Доработан код. Удален пойск мета в тексте, так как для этого есть фильтры. 55 = 1.2 = 56 * Доработан код.
Note: See TracChangeset
for help on using the changeset viewer.