PluginProbe
CryptX / 3.2.18
CryptX v3.2.18
4.2.0 4.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 92 releases
cryptx / cryptx.php

cryptx.php in CryptX 3.2.18, at cryptx.php

155 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: CryptX
4 Plugin URI: http://weber-nrw.de/wordpress/cryptx/
5 Description: No more SPAM by spiders scanning you site for email adresses. With CryptX you can hide all your email adresses, with and without a mailto-link, by converting them using javascript or UNICODE. Although you can choose to add a mailto-link to all unlinked email adresses with only one klick at the settings. That's great, isn't it?
6 Version: 3.2.18
7 Author: Ralf Weber
8 Author URI: http://weber-nrw.de/
9 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696
10 */
11 /**
12 * "CryptX" WordPress Plugin
13 *
14 * @author Ralf Weber <ralf@weber-nrw.de>
15 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
16 */
17
18 //avoid direct calls to this file, because now WP core and framework has been used
19 if ( ! function_exists('add_action') ) {
20 header('Status: 403 Forbidden');
21 header('HTTP/1.1 403 Forbidden');
22 exit();
23 }
24
25 /**
26 * some basics
27 */
28 global $wp_version;
29 define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) );
30 define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
31 define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) );
32 load_plugin_textdomain('cryptx', false, 'cryptx/languages/');
33 require_once(plugin_dir_path( __FILE__ ) . 'functions.php');
34 require_once(plugin_dir_path( __FILE__ ) . 'classes.php');
35 require_once(plugin_dir_path( __FILE__ ) . 'admin.php');
36 $cryptX_var = rw_loadDefaults();
37 $is_js_needed = false;
38
39 foreach($cryptX_var['filter'] as $filter) {
40 if (@$cryptX_var[$filter]) {
41 rw_cryptx_filter($filter);
42 }
43 }
44
45 add_action( 'activate_' . plugin_basename( __FILE__ ), 'rw_cryptx_install' );
46
47 // Register Script
48 function cryptx_javascripts_load() {
49 global $cryptX_var;
50 wp_enqueue_script( 'cryptx.js', plugins_url( '/js/cryptx.min.js' , __FILE__ ), false, false, $cryptX_var['load_java'] );
51 }
52 // Hook into the 'wp_enqueue_scripts' action
53 add_action( 'wp_enqueue_scripts', 'cryptx_javascripts_load' );
54
55
56 if (@$cryptX_var['metaBox']) {
57 add_action('admin_menu', 'rw_cryptx_meta_box');
58 add_action('wp_insert_post', 'rw_cryptx_insert_post' );
59 add_action('wp_update_post', 'rw_cryptx_insert_post' );
60 }
61
62 if ( version_compare( $wp_version, '2.8', '>' ) ) {
63 add_filter( 'plugin_row_meta', 'rw_cryptx_init_row_meta', 10, 2 ); // only 2.8 and higher
64 } else {
65 add_filter( 'plugin_action_links', 'rw_cryptx_init_row_meta', 10, 2 );
66 }
67
68 add_filter( 'init', 'rw_cryptx_init_tinyurl');
69 add_action( 'parse_request', 'rw_cryptx_parse_request');
70
71 add_shortcode( 'cryptx', 'rw_cryptx_shortcode');
72
73 /**
74 * get CryptX Version
75 */
76 function rw_cryptx_version() {
77 if ( ! function_exists( 'get_plugins' ) )
78 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
79 $plugin_folder = get_plugins( '/' . plugin_basename( dirname( __FILE__ ) ) );
80 $plugin_file = basename( ( __FILE__ ) );
81 return $plugin_folder[$plugin_file]['Version'];
82 }
83
84
85 /**
86 * New Template functions...
87 * $content = string to convert
88 * $args = string/array with the following parameters
89 * array('text' => "", 'css_class' => "", 'css_id' => "", 'echo' => 1)
90 * or
91 * "text=&css_class=&css_id=&echo=1"
92 */
93 function encryptx( $content, $args="" ) {
94 global $cryptX_var;
95
96 $is_shortcode = true;
97
98 // Parse incomming $args into an array and merge it with $defaults
99 $encryptx_vars = rw_loadDefaults( $args );
100
101 // OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
102 // extract( $args, EXTR_SKIP );
103
104 $tmp = explode("?", $content);
105 $content = $tmp[0];
106 $params = (!empty($tmp[1]))? $tmp[1] : '';
107 if($encryptx_vars['autolink']) {
108 $content = rw_cryptx_autolink( $content, true );
109 if (!empty($params)) {
110 $content = preg_replace( '/(.*\")(.*)(\".*>)(.*)(<\/a>)/i', '$1$2?'.$params.'$3$4$5', $content );
111 }
112 }
113 $content = rw_cryptx_encryptx( $content, true );
114 $content = rw_cryptx_linktext( $content, true );
115 if(!empty($encryptx_vars['text'])) {
116 $content = preg_replace( '/(.*">)(.*)(<.*)/i', '$1'.$encryptx_vars['text'].'$3', $content );
117 }
118 if(!empty($encryptx_vars['css_id'])) {
119 $content = preg_replace( '/(.*)(">)/i', '$1" id="'.$encryptx_vars['css_id'].'">', $content );
120 }
121 if(!empty($encryptx_vars['css_class'])) {
122 $content = preg_replace( '/(.*)(">)/i', '$1" class="'.$encryptx_vars['css_class'].'">', $content );
123 }
124
125 $is_shortcode = false;
126
127 if(!$encryptx_vars['echo'])
128 return $content;
129
130 echo $content;
131
132 }
133
134 /**
135 * Template function that encrypt the get_post_meta result
136 * call it with the default get_post_meta parameters
137 **/
138 function get_encryptx_meta( $post_id, $key, $single=false ) {
139
140 $values = get_post_meta( $post_id, $key, $single );
141
142 if(is_array($values)) {
143 $return = array();
144 foreach( $values as $value) {
145 $return[] = encryptx($value, array('echo' => 0));
146 }
147 } else {
148 $return = encryptx($values, array('echo' => 0));
149 }
150
151 return $return;
152
153 }
154
155 ?>