├── .gitignore ├── img ├── ad.png └── ribbon.png ├── .gitmodules ├── lib ├── forms │ ├── plugin_settings.php │ ├── ads_loop.php │ ├── ad_single.php │ └── ads_single-alex.php ├── class_wdca_codec.php ├── class_wdca_public_pages.php ├── class_wdca_data.php ├── class_wdca_admin_pages.php ├── class_wdca_custom_ad.php └── class_wdca_admin_form_renderer.php ├── css ├── wdca-default.css ├── wdca-dark.css ├── wdca-wpmu.css ├── wdca-dotted.css ├── wdca.css ├── wdca-greenbutton.css ├── wdca-paper.css ├── wdca-alex.css └── wdca-wpmu2013.css ├── changelog.txt ├── js ├── wdca.js └── wdca-button.js ├── README.md ├── custom-ads.php ├── license.txt └── languages └── wdca-default.po /.gitignore: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /img/ad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/in-post-ads/master/img/ad.png -------------------------------------------------------------------------------- /img/ribbon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/in-post-ads/master/img/ribbon.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dash-notice"] 2 | path = dash-notice 3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /lib/forms/plugin_settings.php: -------------------------------------------------------------------------------- 1 |
| ' + l10nWdca.ad_title + ' | ' + l10nWdca.ad_date + ' | |
|---|---|---|
| ' + l10nWdca.ad_title + ' | ' + l10nWdca.ad_date + ' | |
| ' + ad.post_title + ' | '; 83 | html += '' + ad.post_date + ' | '; 84 | html += '' + l10nWdca.add_ad + ' | '; 85 | html += '
' +
117 | ''
118 | );
119 |
120 | });
121 | })(jQuery);
--------------------------------------------------------------------------------
/lib/class_wdca_admin_pages.php:
--------------------------------------------------------------------------------
1 | add_hooks();
17 | }
18 |
19 | function create_admin_menu_entry () {
20 | if (@$_POST && isset($_POST['option_page'])) {
21 | $changed = false;
22 | $page = !empty($_GET['page']) ? $_GET['page'] : false;
23 | $key = Wdca_Data::AB_MODE_KEY == $page
24 | ? Wdca_Data::AB_MODE_KEY
25 | : Wdca_Data::get_valid_key($page)
26 | ;
27 | if ("{$key}-options" == @$_POST['option_page']) {
28 | update_option($key, stripslashes_deep($_POST[$key]));
29 | $changed = true;
30 | }
31 |
32 | if ($changed) {
33 | $goback = add_query_arg('settings-updated', 'true', wp_get_referer());
34 | wp_redirect($goback);
35 | die;
36 | }
37 | }
38 | /*$page = is_multisite() ? 'settings.php' : 'options-general.php';*/
39 | $page = "edit.php?post_type=" . Wdca_CustomAd::POST_TYPE;
40 | $perms = defined('WDCA_LEGACY_OPTIONS_ACCESS') && WDCA_LEGACY_OPTIONS_ACCESS
41 | ? is_multisite() ? 'manage_network_options' : 'manage_options'
42 | : (is_multisite() && !defined('WDCA_MINIMUM_ADMIN_CAPABILITY') ? 'manage_options' : (defined('WDCA_MINIMUM_ADMIN_CAPABILITY') ? WDCA_MINIMUM_ADMIN_CAPABILITY : 'manage_options'))
43 | ;
44 | if (!Wdca_Data::get_ab_option('enabled')) {
45 | add_submenu_page($page, __('Settings', 'wdca'), __('Settings', 'wdca'), $perms, 'wdca', array($this, 'create_admin_page'));
46 | } else {
47 | add_submenu_page($page, __('Settings (A)', 'wdca'), __('Settings (A)', 'wdca'), $perms, Wdca_Data::DEFAULT_KEY, array($this, 'create_admin_page'));
48 | add_submenu_page($page, __('Settings (B)', 'wdca'), __('Settings (B)', 'wdca'), $perms, Wdca_Data::B_GROUP_KEY, array($this, 'create_admin_page'));
49 | }
50 | add_submenu_page($page, __('A/B Settings', 'wdca'), __('A/B Settings', 'wdca'), $perms, Wdca_Data::AB_MODE_KEY, array($this, 'create_admin_page'));
51 |
52 | }
53 |
54 | function register_settings () {
55 | // Register AB settings
56 | $mode = Wdca_Data::AB_MODE_KEY;
57 | $form = new Wdca_AdminFormRenderer($mode);
58 | register_setting($mode, $mode);
59 | add_settings_section('wdca_settings', __('A/B mode setup', 'wdca'), array($form, 'create_ab_mode_setup_box'), "{$mode}-options");
60 | add_settings_field('wdca_enable', __('Enable A/B testing', 'wdca'), array($form, 'create_enabled_box'), "{$mode}-options", 'wdca_settings');
61 | add_settings_field('wdca_session', __('Track mode in sessions', 'wdca'), array($form, 'create_sessions_box'), "{$mode}-options", 'wdca_settings');
62 | add_settings_field('wdca_b_group_for_admins', __('Always show B group to admins', 'wdca'), array($form, 'create_b_group_for_admins_box'), "{$mode}-options", 'wdca_settings');
63 | add_settings_field('wdca_b_group_for_users', __('Always show B group to all my users', 'wdca'), array($form, 'create_b_group_for_users_box'), "{$mode}-options", 'wdca_settings');
64 | add_settings_field('wdca_get_override', __('GET key override', 'wdca'), array($form, 'create_get_key_override_box'), "{$mode}-options", 'wdca_settings');
65 |
66 | // ... that's done. Now, register mode settings:
67 | if (!Wdca_Data::get_ab_option('enabled')) return $this->register_mode_settings(Wdca_Data::DEFAULT_KEY);
68 |
69 | $this->register_mode_settings(Wdca_Data::DEFAULT_KEY);
70 | $this->register_mode_settings(Wdca_Data::B_GROUP_KEY);
71 | }
72 |
73 | function register_mode_settings ($mode) {
74 | $form = new Wdca_AdminFormRenderer($mode);
75 |
76 | register_setting($mode, $mode);
77 | add_settings_section('wdca_settings', __('Custom Ads', 'wdca'), create_function('', ''), "{$mode}-options");
78 | add_settings_field('wdca_enable', __('Enable Custom Ads', 'wdca'), array($form, 'create_enabled_box'), "{$mode}-options", 'wdca_settings');
79 | add_settings_field('wdca_test', __('Live mode', 'wdca'), array($form, 'create_live_mode_box'), "{$mode}-options", 'wdca_settings');
80 | add_settings_field('wdca_ad_count', __('Show this many Ads', 'wdca'), array($form, 'create_ad_count_box'), "{$mode}-options", 'wdca_settings');
81 | add_settings_field('wdca_ad_order', __('Order Ads by', 'wdca'), array($form, 'create_ad_order_box'), "{$mode}-options", 'wdca_settings');
82 | add_settings_field('wdca_p_first_count', __('Inject first Ad after this many paragraphs', 'wdca'), array($form, 'create_p_first_count_box'), "{$mode}-options", 'wdca_settings');
83 | add_settings_field('wdca_p_count', __('Inject subsequent Ads after this many paragraphs each', 'wdca'), array($form, 'create_p_count_box'), "{$mode}-options", 'wdca_settings');
84 | add_settings_field('wdca_ad_delay', __('Delayed Ads insertion', 'wdca'), array($form, 'create_ad_show_after_box'), "{$mode}-options", 'wdca_settings');
85 | add_settings_field('wdca_predefined_positions', __('Predefined positions', 'wdca'), array($form, 'create_predefined_positions_box'), "{$mode}-options", 'wdca_settings');
86 |
87 | add_settings_section('wdca_appearance', __('Appearance & messages', 'wdca'), create_function('', ''), "{$mode}-options");
88 | add_settings_field('wdca_theme', __('Theme', 'wdca'), array($form, 'create_theme_box'), "{$mode}-options", 'wdca_appearance');
89 | add_settings_field('wdca_messages', __('Messages', 'wdca'), array($form, 'create_messages_box'), "{$mode}-options", 'wdca_appearance');
90 | add_settings_field('wdca_link', __('Link click', 'wdca'), array($form, 'create_link_box'), "{$mode}-options", 'wdca_appearance');
91 |
92 | add_settings_section('wdca_analytics', __('Google Analytics Integration', 'wdca'), array($form, 'create_ga_setup_box'), "{$mode}-options");
93 | add_settings_field('wdca_ga_integration', __('Enable Google Analytics integration', 'wdca'), array($form, 'create_ga_integration_box'), "{$mode}-options", 'wdca_analytics');
94 | add_settings_field('wdca_ga_category', __('Event category', 'wdca'), array($form, 'create_ga_category_box'), "{$mode}-options", 'wdca_analytics');
95 | add_settings_field('wdca_ga_label', __('Event label', 'wdca'), array($form, 'create_ga_label_box'), "{$mode}-options", 'wdca_analytics');
96 |
97 | add_settings_section('wdca_advanced', __('Advanced', 'wdca'), create_function('', ''), "{$mode}-options");
98 | add_settings_field('wdca_allow_post_types', __('Custom post types Ads', 'wdca'), array($form, 'create_cpt_ads_box'), "{$mode}-options", 'wdca_advanced');
99 | add_settings_field('wdca_post_metabox', __('Show post metabox', 'wdca'), array($form, 'create_post_metabox_box'), "{$mode}-options", 'wdca_advanced');
100 | add_settings_field('wdca_to_categories', __('Connect post categories', 'wdca'), array($form, 'create_categories_box'), "{$mode}-options", 'wdca_advanced');
101 | add_settings_field('wdca_to_tags', __('Connect post tags', 'wdca'), array($form, 'create_tags_box'), "{$mode}-options", 'wdca_advanced');
102 | add_settings_field('wdca_elements', __('Elements selector', 'wdca'), array($form, 'create_selector_box'), "{$mode}-options", 'wdca_advanced');
103 | add_settings_field('wdca_lazy_loading', __('Lazy loading', 'wdca'), array($form, 'create_lazy_loading_box'), "{$mode}-options", 'wdca_advanced');
104 | }
105 |
106 | function create_admin_page () {
107 | $option_key = $title = false;
108 | if (!empty($_GET['page']) && Wdca_Data::AB_MODE_KEY == $_GET['page']) {
109 | $option_key = Wdca_Data::AB_MODE_KEY;
110 | $title = __('A/B Settings', 'wdca');
111 | } else {
112 | $option_key = Wdca_Data::get_ab_option('enabled')
113 | ? Wdca_Data::get_valid_key(@$_GET['page'])
114 | : Wdca_Data::DEFAULT_KEY
115 | ;
116 | $title = !Wdca_Data::get_ab_option('enabled')
117 | ? __('Settings', 'wdca')
118 | : (Wdca_Data::DEFAULT_KEY == Wdca_Data::get_valid_key(@$_GET['page'])
119 | ? __('Settings (A)', 'wdca')
120 | : __('Settings (B)', 'wdca')
121 | )
122 | ;
123 | }
124 | include(WDCA_PLUGIN_BASE_DIR . '/lib/forms/plugin_settings.php');
125 | }
126 |
127 | function js_print_scripts () {
128 | printf(
129 | '',
134 | WDCA_PLUGIN_URL
135 | );
136 | }
137 |
138 | function js_editor_button () {
139 | wp_enqueue_script('wdca_editor', WDCA_PLUGIN_URL . '/js/wdca-button.js', array('jquery'));
140 | wp_localize_script('wdca_editor', 'l10nWdca', array(
141 | 'add_ad' => __('Insert Ad', 'wdca'),
142 | 'ad_title' => __('Title', 'wdca'),
143 | 'ad_date' => __('Date', 'wdca'),
144 | 'appearance' => __('Appearance', 'wdca'),
145 | 'add_blank' => __('Insert blank placeholder for an ad', 'wdca'),
146 | 'or_select_below' => __('or select an Ad to insert from the ones listed below', 'wdca'),
147 | 'dflt' => __('Default', 'wdca'),
148 | 'ad_size' => __('Size', 'wdca'),
149 | 'small' => __('Small', 'wdca'),
150 | 'medium' => __('Medium', 'wdca'),
151 | 'large' => __('Large', 'wdca'),
152 | 'ad_position' => __('Position', 'wdca'),
153 | 'left' => __('Left', 'wdca'),
154 | 'right' => __('Right', 'wdca'),
155 | ));
156 | }
157 |
158 | function css_print_styles () {
159 | }
160 |
161 | public function add_meta_boxes () {
162 | add_meta_box(
163 | 'wdca_prevent_ad_insertion',
164 | __('In Post Ads', 'wdca'),
165 | array($this, 'render_prevent_ad_box'),
166 | 'post',
167 | 'side',
168 | 'low'
169 | );
170 | }
171 |
172 | public function render_prevent_ad_box () {
173 | global $post;
174 | $post_id = wp_is_post_revision($post);
175 | $post_id = $post_id ? $post_id : $post->ID;
176 |
177 | $opts = get_option('wdca');
178 | $prevent_items = @$opts['prevent_items'];
179 | $prevent_items = is_array($prevent_items) ? $prevent_items : array();
180 | $checked = in_array($post_id, $prevent_items) ? 'checked="checked"' : '';
181 | echo ""; 182 | echo '
'; 183 | } 184 | 185 | function save_meta () { 186 | global $post; 187 | 188 | $post_id = wp_is_post_revision($post); 189 | $post_id = $post_id ? $post_id : (is_object($post) ? $post->ID : false); 190 | if (empty($post_id)) return false; 191 | 192 | $opts = get_option('wdca'); 193 | $opts = $opts ? $opts : array(); 194 | $opts['prevent_items'] = @$opts['prevent_items'] ? $opts['prevent_items'] : array(); 195 | 196 | if (isset($_POST['wdca_hide_box'])) { 197 | $opts['prevent_items'][] = $post_id; 198 | } else { 199 | $key = array_search($post_id, $opts['prevent_items']); 200 | if (false !== $key) unset($opts['prevent_items'][$key]); 201 | } 202 | $opts['prevent_items'] = array_unique($opts['prevent_items']); 203 | update_option('wdca', $opts); 204 | } 205 | 206 | /** 207 | * Handles ad listing requests. 208 | */ 209 | function json_list_ads () { 210 | $ads = Wdca_CustomAd::get_all_ads(); 211 | header('Content-type: application/json'); 212 | echo json_encode($ads); 213 | exit(); 214 | } 215 | 216 | function add_hooks () { 217 | add_action('admin_init', array($this, 'register_settings')); 218 | $hook = /*is_multisite() ? 'network_admin_menu' :*/ 'admin_menu'; 219 | add_action($hook, array($this, 'create_admin_menu_entry')); 220 | 221 | add_action('admin_init', array($this, 'add_meta_boxes')); 222 | add_action('save_post', array($this, 'save_meta')); 223 | 224 | add_action('admin_print_scripts', array($this, 'js_print_scripts')); 225 | add_action('admin_print_styles', array($this, 'css_print_styles')); 226 | 227 | add_action('admin_print_scripts-post.php', array($this, 'js_editor_button')); 228 | add_action('admin_print_scripts-post-new.php', array($this, 'js_editor_button')); 229 | 230 | add_action('wp_ajax_wdca_list_ads', array($this, 'json_list_ads')); 231 | 232 | // Dashboard 233 | if (file_exists(WDCA_PLUGIN_BASE_DIR . '/dash-notice/wpmudev-dash-notification.php')) { 234 | global $wpmudev_notices; 235 | $wpmudev_notices[] = array( 236 | 'id' => 240, 237 | 'name' => 'In Post Ads', 238 | 'screens' => array( 239 | 'wdca_custom_ad_page_wdca', 240 | 'wdca_custom_ad_page_wdca-ab', 241 | ), 242 | ); 243 | 244 | require_once(WDCA_PLUGIN_BASE_DIR . '/dash-notice/wpmudev-dash-notification.php'); 245 | } 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /lib/class_wdca_custom_ad.php: -------------------------------------------------------------------------------- 1 | _data = Wdca_Data::get_options();//get_option('wdca'); 18 | } 19 | 20 | public static function init () { 21 | $me = self::get_instance(); 22 | add_action('init', array($me, 'register_post_type')); 23 | add_action('admin_init', array($me, 'add_meta_boxes')); 24 | add_action('save_post', array($me, 'save_ad_meta')); 25 | 26 | add_filter("manage_edit-" . self::POST_TYPE . "_columns", array($me, "add_custom_columns")); 27 | add_action("manage_posts_custom_column", array($me, "fill_custom_columns")); 28 | 29 | $stylesheet_type = !empty($me->_data['style_inclusion_type']) ? $me->_data['style_inclusion_type'] : ''; 30 | if ('dynamic' == $stylesheet_type) { 31 | $pfx = self::wrap('get_styles'); 32 | add_action("wp_ajax_{$pfx}", array($me, 'json_load_styles')); 33 | add_action("wp_ajax_nopriv_{$pfx}", array($me, 'json_load_styles')); 34 | } 35 | 36 | add_filter('wdca_the_content', 'capital_P_dangit', 11); 37 | add_filter('wdca_the_content', 'wptexturize'); 38 | add_filter('wdca_the_content', 'convert_smilies'); 39 | add_filter('wdca_the_content', 'convert_chars'); 40 | add_filter('wdca_the_content', 'wpautop'); 41 | add_filter('wdca_the_content', 'shortcode_unautop'); 42 | add_filter('wdca_the_content', 'prepend_attachment'); 43 | add_filter('wdca_the_content', 'do_shortcode'); 44 | } 45 | 46 | public static function get_instance () { 47 | if (!self::$_instance) self::$_instance = new Wdca_CustomAd; 48 | return self::$_instance; 49 | } 50 | 51 | public function register_post_type () { 52 | register_post_type(self::POST_TYPE, array( 53 | 'labels' => array( 54 | 'name' => __('In Post Ads', 'wdca'), 55 | 'singular_name' => __('In Post Ad', 'wdca'), 56 | 'add_new_item' => __('Add new In Post Ad', 'wdca'), 57 | 'edit_item' => __('Edit In Post Ad', 'wdca'), 58 | ), 59 | 'public' => true, 60 | 'supports' => array( 61 | 'title', 'editor', 'thumbnail' 62 | ), 63 | 'rewrite' => false, 64 | 'capabilities' => array( 65 | 'publish_posts' => 'manage_options', 66 | 'edit_posts' => 'manage_options', 67 | 'edit_others_posts' => 'manage_options', 68 | 'delete_posts' => 'manage_options', 69 | 'delete_others_posts' => 'manage_options', 70 | 'read_private_posts' => 'manage_options', 71 | 'edit_post' => 'manage_options', 72 | 'delete_post' => 'manage_options', 73 | 'read_post' => 'read_post', 74 | ), 75 | )); 76 | 77 | register_taxonomy('wdca_ad_categories', self::POST_TYPE, array( 78 | 'labels' => array( 79 | 'name' => __('Ad Categories', 'wdca'), 80 | 'singular_name' => __('Ad Category', 'wdca'), 81 | 'add_new_item' => __('Add new Ad Category', 'wdca'), 82 | 'edit_item' => __('Edit Ad Category', 'wdca'), 83 | 'search_items' => __('Search Ad Categories', 'wdca'), 84 | 'popular_items' => __('Popular Ad Categories', 'wdca'), 85 | 'all_items' => __('All Ad Categories', 'wdca'), 86 | 'separate_items_with_commas' => __('Separate Ad Categories with commas', 'wdca'), 87 | 'add_or_remove_items' => __('Add or remove Ad Categories', 'wdca'), 88 | 'choose_from_most_used' => __('Choose from most used Ad Categories', 'wdca'), 89 | ), 90 | 'public' => true, 91 | 'show_in_nav_menus' => false, 92 | 'show_tagcloud' => false, 93 | 'hierarchical' => false, 94 | 'rewrite' => false, 95 | )); 96 | } 97 | 98 | public function add_custom_columns ($cols) { 99 | return array_merge($cols, array( 100 | 'ad_categories' => __('Ad Categories', 'wdca'), 101 | )); 102 | } 103 | 104 | public function fill_custom_columns ($col) { 105 | global $post; 106 | if ('ad_categories' != $col) return $col; 107 | echo get_the_term_list($post->ID, 'wdca_ad_categories', '', ', ', ''); 108 | } 109 | 110 | public function add_meta_boxes () { 111 | add_meta_box( 112 | 'wdca_plugin_link', 113 | __('Ad link', 'wdca'), 114 | array($this, 'render_link_box'), 115 | self::POST_TYPE, 116 | 'side', 117 | 'high' 118 | ); 119 | add_meta_box( 120 | 'wdca_ad_appearance', 121 | __('Ad appearance', 'wdca'), 122 | array($this, 'render_appearance_box'), 123 | self::POST_TYPE, 124 | 'side', 125 | 'low' 126 | ); 127 | } 128 | 129 | public function render_link_box () { 130 | global $post; 131 | $link = get_post_meta($post->ID, 'wdca_plugin_url', true); 132 | echo ''; 133 | echo "
"; 134 | } 135 | 136 | public function render_appearance_box () { 137 | global $post; 138 | $appearance = get_post_meta($post->ID, 'wdca_appearance', true); 139 | $title = @$appearance['hide_title'] ? 'checked="checked"' : ''; 140 | $body = @$appearance['hide_body'] ? 'checked="checked"' : ''; 141 | $footer = @$appearance['hide_footer'] ? 'checked="checked"' : ''; 142 | $strip_class = @$appearance['strip_class'] ? 'checked="checked"' : ''; 143 | echo '' . 144 | '' . 145 | " " . 146 | '' . 147 | '
'; 148 | echo '' . 149 | '' . 150 | " " . 151 | '' . 152 | '
'; 153 | echo ''. 154 | '' . 155 | " " . 156 | '' . 157 | '
'; 158 | echo '' . 159 | '' . 160 | " " . 161 | '' . 162 | '
'; 163 | } 164 | 165 | public function save_ad_meta () { 166 | global $post; 167 | if (@$_POST['wdca_plugin_url']) { 168 | update_post_meta($post->ID, "wdca_plugin_url", $_POST["wdca_plugin_url"]); 169 | } 170 | if (@$_POST['wdca_appearance']) { 171 | update_post_meta($post->ID, "wdca_appearance", $_POST["wdca_appearance"]); 172 | } 173 | } 174 | 175 | public static function get_all_ads () { 176 | $q = new Wp_Query(array( 177 | 'post_type' => self::POST_TYPE, 178 | 'posts_per_page' => -1, 179 | 'orderby' => 'title', 180 | )); 181 | return $q->posts; 182 | } 183 | 184 | public static function get_ads () { 185 | if (!self::$_cache) self::populate_cache(); 186 | return self::$_cache; 187 | } 188 | 189 | public static function get_ad ($id) { 190 | if (!$id) return self::pull_add_from_cache(); 191 | $ad = get_post($id); 192 | self::$_cache_ids[] = $ad->ID; 193 | return $ad; 194 | } 195 | 196 | private static function populate_cache () { 197 | $opts = Wdca_Data::get_options();//get_option('wdca'); 198 | 199 | if (!current_user_can('manage_options') && !@$opts['live_mode']) return false; 200 | 201 | $limit = (int)@$opts['ad_count']; 202 | if (!$limit) return false; 203 | 204 | $orders = array('rand', 'title', 'date', 'modified'); 205 | $bys = array('ASC', 'DESC'); 206 | 207 | $order = @$opts['ad_order']; 208 | $order = in_array($order, $orders) ? $order : 'rand'; 209 | 210 | $by = @$opts['ad_order_by']; 211 | $by = in_array($by, $bys) ? $by : 'ASC'; 212 | 213 | // Handle Ad2Post categories 214 | global $post; 215 | $ad_cat_ids = array(); 216 | $cats_to_ads = !empty($opts['category_ads']) ? $opts['category_ads'] : array(); 217 | $cats_to_ads = is_array($cats_to_ads) ? $cats_to_ads : array(); 218 | $categories = get_the_category($post->ID); 219 | 220 | foreach ($categories as $cat) { 221 | if (isset($cats_to_ads[$cat->term_id])) foreach ($cats_to_ads[$cat->term_id] as $ad_id) $ad_cat_ids[] = $ad_id; 222 | } 223 | 224 | // Ad2Post tags 225 | $tags_to_ads = !empty($opts['tag_ads']) ? $opts['tag_ads'] : array(); 226 | $tags_to_ads = is_array($tags_to_ads) ? $tags_to_ads : array(); 227 | $tags = wp_get_post_tags($post->ID); 228 | foreach ($tags as $tag) { 229 | if (isset($tags_to_ads[$tag->term_id])) foreach ($tags_to_ads[$tag->term_id] as $ad_id) $ad_cat_ids[] = $ad_id; 230 | } 231 | $ad_cat_ids = array_unique($ad_cat_ids); 232 | 233 | //we will have to check if the cat/tag to ads enabled, but can't find, so we will put a negative here 234 | if((count($cats_to_ads)||count($tags_to_ads)) && empty($ad_cat_ids)){ 235 | $ad_cat_ids[]=-1; 236 | } 237 | 238 | $query_args = array( 239 | 'post__not_in' => self::$_cache_ids, 240 | 'post_type' => self::POST_TYPE, 241 | 'showposts' => $limit, 242 | 'orderby' => $order, 243 | 'order' => $by, 244 | ); 245 | 246 | if ($ad_cat_ids) { 247 | $query_args['tax_query'][] = array( 248 | 'taxonomy' => 'wdca_ad_categories', 249 | 'field' => 'id', 250 | 'terms' => $ad_cat_ids, 251 | ); 252 | } 253 | $q = new Wp_Query($query_args); 254 | self::$_cache = $q->posts; 255 | 256 | foreach ($q->posts as $ad) { 257 | self::$_cache_ids[] = $ad->ID; 258 | } 259 | } 260 | 261 | private static function pull_add_from_cache () { 262 | if (!self::$_cache) self::populate_cache(); 263 | $ad = is_array(self::$_cache) ? array_pop(self::$_cache) : false; 264 | return $ad; 265 | } 266 | 267 | public function get_ad_template () { 268 | $default_template = 'ad_single.php'; 269 | $potential_template = !empty($this->_data['theme']) ? sprintf('ads_single-%s.php', $this->_data['theme']) : $default_template; 270 | return 271 | file_exists(WDCA_PLUGIN_BASE_DIR . "/lib/forms/{$potential_template}") 272 | ? WDCA_PLUGIN_BASE_DIR . "/lib/forms/{$potential_template}" 273 | : WDCA_PLUGIN_BASE_DIR . "/lib/forms/{$default_template}" 274 | ; 275 | } 276 | 277 | /* ----- Dependency loading ----- */ 278 | 279 | public function include_frontend_javascript () { 280 | if (defined('WDCA_FLAG_JAVASCRIPT_LOADED')) return false; 281 | 282 | wp_enqueue_script('jquery'); 283 | wp_enqueue_script('wdca', WDCA_PLUGIN_URL . '/js/wdca.js', array('jquery'), '1.5.1'); 284 | 285 | $stylesheet_type = !empty($this->_data['style_inclusion_type']) ? $this->_data['style_inclusion_type'] : ''; 286 | 287 | $wdca_data = array( 288 | "first_ad" => (!empty($this->_data['p_first_count']) ? (int)$this->_data['p_first_count'] : 0), 289 | "count" => (!empty($this->_data['p_count']) ? (int)$this->_data['p_count'] : 0), 290 | "selector" => (!empty($this->_data['selector']) ? $this->_data['selector'] : '>p'), 291 | "predefined" => array( 292 | "before" => (int)(!empty($this->_data['predefined_before_first_p'])), 293 | "middle" => (int)(!empty($this->_data['predefined_halfway_through'])), 294 | "after" => (int)(!empty($this->_data['predefined_after_last_p'])), 295 | "ignore_other" => (int)(!empty($this->_data['predefined_ignore_other'])), 296 | 'ignore_requirement' => (int)(!empty($this->_data['predefined_ignore_other-paragraph_count']) ? $this->_data['predefined_ignore_other-paragraph_count'] : 0), 297 | ), 298 | "ga" => array( 299 | "enabled" => !empty($this->_data['ga_integration']), 300 | "category" => (!empty($this->_data['ga_category']) ? esc_js($this->_data['ga_category']) : ''), 301 | "label" => (!empty($this->_data['ga_label']) ? esc_js($this->_data['ga_label']) : ''), 302 | ), 303 | "non_indexing_wrapper" => (defined('WDCA_FLAG_FORCE_NON_INDEXING_WRAPPER') && WDCA_FLAG_FORCE_NON_INDEXING_WRAPPER), 304 | "pfx" => self::wrap(''), 305 | "dynamic_styles" => ('dynamic' == $stylesheet_type), 306 | "ajax_url" => admin_url('admin-ajax.php'), 307 | ); 308 | echo ''; 309 | 310 | define('WDCA_FLAG_JAVASCRIPT_LOADED', true, true); 311 | } 312 | 313 | public function include_frontend_stylesheet () { 314 | if (defined('WDCA_FLAG_STYLESHEET_LOADED')) return false; 315 | 316 | $theme = @$this->_data['theme']; 317 | $theme = $theme ? $theme : 'default'; 318 | 319 | $stylesheet_type = !empty($this->_data['style_inclusion_type']) ? $this->_data['style_inclusion_type'] : ''; 320 | 321 | if (!current_theme_supports('wdca')) { 322 | if (empty($stylesheet_type)) wp_enqueue_style('wdca', WDCA_PLUGIN_URL . "/css/wdca.css"); 323 | else if ('dynamic' != $stylesheet_type) add_action($this->get_late_binding_hook(), array($this, 'inject_inline_styles'), 99); 324 | 325 | if (!file_exists(WDCA_PLUGIN_BASE_DIR . "/css/wdca-{$theme}.css")) return false; 326 | 327 | if (empty($stylesheet_type)) wp_enqueue_style('wdca-theme', WDCA_PLUGIN_URL . "/css/wdca-{$theme}.css"); 328 | else if ('dynamic' != $stylesheet_type) add_action($this->get_late_binding_hook(), array($this, 'inject_inline_styles'), 99); 329 | } 330 | define('WDCA_FLAG_STYLESHEET_LOADED', true, true); 331 | } 332 | 333 | private function _get_processed_styles () { 334 | $theme = !empty($this->_data['theme']) 335 | ? $this->_data['theme'] 336 | : 'default' 337 | ; 338 | $theme = preg_replace('/[^-_a-z0-9]/i', '', $theme); 339 | $file = !empty($theme) 340 | ? WDCA_PLUGIN_BASE_DIR . "/css/wdca-{$theme}.css" 341 | : WDCA_PLUGIN_BASE_DIR . "/css/wdca.css" 342 | ; 343 | if (!file_exists($file)) return false; 344 | $style = file_get_contents($file); 345 | if (empty($style)) return false; 346 | 347 | $pfx = self::wrap(''); 348 | $style = preg_replace('/wdca_/', $pfx, $style); 349 | return $style; 350 | } 351 | 352 | public function inject_inline_styles () { 353 | $style = $this->_get_processed_styles(); 354 | if (!empty($style)) echo ""; 355 | } 356 | 357 | public function json_load_styles () { 358 | $style = $this->_get_processed_styles(); 359 | wp_send_json(array( 360 | 'style' => $style, 361 | )); 362 | } 363 | 364 | public function get_late_binding_hook () { 365 | $hook = @$this->_data['late_binding_hook']; 366 | $hook = $hook ? $hook : 'wp_footer'; 367 | $hook = defined('WDCA_FOOTER_HOOK') && WDCA_FOOTER_HOOK 368 | ? WDCA_FOOTER_HOOK 369 | : $hook 370 | ; 371 | return apply_filters('wdca-core-footer_hook', $hook); 372 | } 373 | 374 | /** 375 | * Used for late binding dependencies. 376 | */ 377 | public function late_bind_frontend_dependencies () { 378 | if (defined('WDCA_FLAG_LATE_INCLUSION_BOUND')) return false; 379 | if (defined('WDCA_FLAG_JAVASCRIPT_LOADED') && defined('WDCA_FLAG_STYLESHEET_LOADED')) return false; 380 | 381 | $hook = $this->get_late_binding_hook(); 382 | if (!$hook) return false; 383 | 384 | add_action($hook, array($this, 'include_frontend_stylesheet'), 18); 385 | add_action($hook, array($this, 'include_frontend_javascript'), 19); 386 | 387 | define('WDCA_FLAG_LATE_INCLUSION_BOUND', true, true); 388 | } 389 | 390 | public static function get_root_prefix () { 391 | $data = Wdca_Data::get_options(); 392 | if (empty($data['style_inclusion_type'])) return 'wdca'; 393 | 394 | $full = md5(home_url() . COOKIEHASH); 395 | $idx = substr(preg_replace('/\D/', '', $full), 0, 1); 396 | $letters = range('a', 'z'); 397 | if (!preg_match('/^[a-z]/i', $full)) $full = $letters[$idx] . $full; 398 | return substr($full, 0, 5); 399 | } 400 | 401 | public static function wrap ($str) { 402 | return self::get_root_prefix() . "_{$str}"; 403 | } 404 | } 405 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Library General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | -------------------------------------------------------------------------------- /languages/wdca-default.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: In Post Ads\n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "POT-Creation-Date: 2013-12-14 16:25+0100\n" 6 | "PO-Revision-Date: 2013-12-14 16:25+0100\n" 7 | "Last-Translator: \n" 8 | "Language-Team: Incsub\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Poedit-KeywordsList: __;_e\n" 13 | "X-Poedit-Basepath: /Volumes/Trunk/xampp/htdocs/wdorg/wp-content/plugins/" 14 | "custom-ads\n" 15 | "X-Generator: Poedit 1.5.5\n" 16 | "X-Poedit-SearchPath-0: lib\n" 17 | "X-Poedit-SearchPath-1: lib/forms\n" 18 | 19 | #: lib/class_wdca_admin_form_renderer.php:23 20 | msgid "Yes" 21 | msgstr "" 22 | 23 | #: lib/class_wdca_admin_form_renderer.php:26 24 | msgid "No" 25 | msgstr "" 26 | 27 | #: lib/class_wdca_admin_form_renderer.php:59 28 | msgid "Disabling this will only show your ads to logged in users" 29 | msgstr "" 30 | 31 | #: lib/class_wdca_admin_form_renderer.php:60 32 | msgid "Do NOT turn this on until you are ready to go live" 33 | msgstr "" 34 | 35 | #: lib/class_wdca_admin_form_renderer.php:65 36 | msgid "This many Ads will be shown per post page" 37 | msgstr "" 38 | 39 | #: lib/class_wdca_admin_form_renderer.php:70 40 | msgid "Random" 41 | msgstr "" 42 | 43 | #: lib/class_wdca_admin_form_renderer.php:71 44 | #: lib/class_wdca_admin_pages.php:146 45 | msgid "Title" 46 | msgstr "" 47 | 48 | #: lib/class_wdca_admin_form_renderer.php:72 49 | #: lib/class_wdca_admin_pages.php:147 50 | msgid "Date" 51 | msgstr "" 52 | 53 | #: lib/class_wdca_admin_form_renderer.php:73 54 | msgid "Modified" 55 | msgstr "" 56 | 57 | #: lib/class_wdca_admin_form_renderer.php:95 58 | msgid "Your Ads will be ordered in the way you set up here" 59 | msgstr "" 60 | 61 | #: lib/class_wdca_admin_form_renderer.php:100 62 | msgid "Your first Ad will be injected in your post after this many paragraphs." 63 | msgstr "" 64 | 65 | #: lib/class_wdca_admin_form_renderer.php:104 66 | msgid "" 67 | "Your subsequent Ads will be injected in your post every [number] of " 68 | "paragraphs." 69 | msgstr "" 70 | 71 | #: lib/class_wdca_admin_form_renderer.php:111 72 | msgid "immediately" 73 | msgstr "" 74 | 75 | #: lib/class_wdca_admin_form_renderer.php:115 76 | #, php-format 77 | msgid "%d days" 78 | msgstr "" 79 | 80 | #: lib/class_wdca_admin_form_renderer.php:116 81 | #, php-format 82 | msgid "%d day" 83 | msgstr "" 84 | 85 | #: lib/class_wdca_admin_form_renderer.php:121 86 | #, php-format 87 | msgid "Show my Ads %s after the post gets published" 88 | msgstr "" 89 | 90 | #: lib/class_wdca_admin_form_renderer.php:122 91 | msgid "" 92 | "Use this option to delay automatic Ads injection for a selected time period." 93 | msgstr "" 94 | 95 | #: lib/class_wdca_admin_form_renderer.php:127 96 | msgid "Before first paragraph:" 97 | msgstr "" 98 | 99 | #: lib/class_wdca_admin_form_renderer.php:130 100 | msgid "" 101 | "Enabling this option will insert your first Ad at the very begining of your " 102 | "post" 103 | msgstr "" 104 | 105 | #: lib/class_wdca_admin_form_renderer.php:133 106 | msgid "Halway through your post:" 107 | msgstr "" 108 | 109 | #: lib/class_wdca_admin_form_renderer.php:136 110 | msgid "Enabling this option will insert an Ad halway through your post" 111 | msgstr "" 112 | 113 | #: lib/class_wdca_admin_form_renderer.php:139 114 | msgid "After last paragraph:" 115 | msgstr "" 116 | 117 | #: lib/class_wdca_admin_form_renderer.php:142 118 | msgid "" 119 | "Enabling this option will insert your first Ad at the very end of your post" 120 | msgstr "" 121 | 122 | #: lib/class_wdca_admin_form_renderer.php:148 123 | msgid "Ignore other injection settings:" 124 | msgstr "" 125 | 126 | #: lib/class_wdca_admin_form_renderer.php:151 127 | msgid "" 128 | "Enabling this option will ignore other injection settings and insert your " 129 | "Ads at the selected predefined settings only" 130 | msgstr "" 131 | 132 | #: lib/class_wdca_admin_form_renderer.php:152 133 | #, php-format 134 | msgid "... but only on posts longer than %s paragraphs" 135 | msgstr "" 136 | 137 | #: lib/class_wdca_admin_form_renderer.php:153 138 | msgid "" 139 | "If your posts are shorter than the number of paragraphs entered here, the " 140 | "default behavior will take precedence over the predefined positions " 141 | "injection." 142 | msgstr "" 143 | 144 | #: lib/class_wdca_admin_form_renderer.php:154 145 | msgid "Leave the value at0 to disable this behavior."
146 | msgstr ""
147 |
148 | #: lib/class_wdca_admin_form_renderer.php:160
149 | #: lib/class_wdca_admin_pages.php:151
150 | msgid "Default"
151 | msgstr ""
152 |
153 | #: lib/class_wdca_admin_form_renderer.php:161
154 | msgid "WPMU.org"
155 | msgstr ""
156 |
157 | #: lib/class_wdca_admin_form_renderer.php:162
158 | msgid "Dark"
159 | msgstr ""
160 |
161 | #: lib/class_wdca_admin_form_renderer.php:163
162 | msgid "Dotted"
163 | msgstr ""
164 |
165 | #: lib/class_wdca_admin_form_renderer.php:164
166 | msgid "Green Button"
167 | msgstr ""
168 |
169 | #: lib/class_wdca_admin_form_renderer.php:165
170 | msgid "wpmu.org 2013"
171 | msgstr ""
172 |
173 | #: lib/class_wdca_admin_form_renderer.php:166
174 | msgid "Paper (modern browsers only)"
175 | msgstr ""
176 |
177 | #: lib/class_wdca_admin_form_renderer.php:180
178 | msgid "Header text"
179 | msgstr ""
180 |
181 | #: lib/class_wdca_admin_form_renderer.php:180
182 | msgid "This text will appear in your Ad header, before the link"
183 | msgstr ""
184 |
185 | #: lib/class_wdca_admin_form_renderer.php:181
186 | msgid "Footer text"
187 | msgstr ""
188 |
189 | #: lib/class_wdca_admin_form_renderer.php:181
190 | msgid "This text will appear below your Ad content, before the link"
191 | msgstr ""
192 |
193 | #: lib/class_wdca_admin_form_renderer.php:182
194 | msgid "Footer link text"
195 | msgstr ""
196 |
197 | #: lib/class_wdca_admin_form_renderer.php:182
198 | msgid "This text will appear as link text in your footer"
199 | msgstr ""
200 |
201 | #: lib/class_wdca_admin_form_renderer.php:188
202 | msgid "Opens in current window/tab"
203 | msgstr ""
204 |
205 | #: lib/class_wdca_admin_form_renderer.php:192
206 | msgid "Opens in new window/tab"
207 | msgstr ""
208 |
209 | #: lib/class_wdca_admin_form_renderer.php:198
210 | msgid ""
211 | "Note: your pages need to already be set up for Google Analytics "
212 | "tracking for this to work properly."
213 | msgstr ""
214 |
215 | #: lib/class_wdca_admin_form_renderer.php:227
216 | msgid ""
217 | "If you are experiencing problems with your theme, you may want to change the "
218 | "default selector to something more generic - e.g. p"
219 | msgstr ""
220 |
221 | #: lib/class_wdca_admin_form_renderer.php:228
222 | msgid ""
223 | "You can also use this box to allow Ad inserting after other elements too - e."
224 | "g. ul,ol,p"
225 | msgstr ""
226 |
227 | #: lib/class_wdca_admin_form_renderer.php:249
228 | msgid ""
229 | "The plugin will auto-insert Ads into your Posts by default. Select "
230 | "additional post types here."
231 | msgstr ""
232 |
233 | #: lib/class_wdca_admin_form_renderer.php:252
234 | msgid "Do not auto-inject into posts:"
235 | msgstr ""
236 |
237 | #: lib/class_wdca_admin_form_renderer.php:256
238 | msgid ""
239 | "These settings apply to auto-insertion only - you will still be able to "
240 | "insert the Ads using shortcodes."
241 | msgstr ""
242 |
243 | #: lib/class_wdca_admin_form_renderer.php:261
244 | msgid ""
245 | "Enabling this option will add a metabox to your post editor interface, which "
246 | "you can use to prevent Ad insertion per post."
247 | msgstr ""
248 |
249 | #: lib/class_wdca_admin_form_renderer.php:289
250 | msgid "My posts within this Category"
251 | msgstr ""
252 |
253 | #: lib/class_wdca_admin_form_renderer.php:289
254 | #: lib/class_wdca_admin_form_renderer.php:341
255 | msgid "will only show Ads from these Ad Categories"
256 | msgstr ""
257 |
258 | #: lib/class_wdca_admin_form_renderer.php:293
259 | #: lib/class_wdca_admin_form_renderer.php:345
260 | msgid ""
261 | "If you do not set any mappings here, any Ad could appear in any of your "
262 | "posts."
263 | msgstr ""
264 |
265 | #: lib/class_wdca_admin_form_renderer.php:341
266 | msgid "My posts within this Tag"
267 | msgstr ""
268 |
269 | #: lib/class_wdca_admin_form_renderer.php:369
270 | msgid "Enable lazy dependency loading:"
271 | msgstr ""
272 |
273 | #: lib/class_wdca_admin_form_renderer.php:372
274 | msgid ""
275 | "Lazy dependency loading can improve your site load times by requiring "
276 | "resources as they are needed."
277 | msgstr ""
278 |
279 | #: lib/class_wdca_admin_form_renderer.php:378
280 | msgid "Lazy loading hook (advanced):"
281 | msgstr ""
282 |
283 | #: lib/class_wdca_admin_form_renderer.php:380
284 | msgid ""
285 | "Lazy dependency loading relies on footer hook to deploy properly. If your "
286 | "theme does not implement the default hook, use this field to set your custom "
287 | "one."
288 | msgstr ""
289 |
290 | #: lib/class_wdca_admin_form_renderer.php:383
291 | msgid "Style inclusion type"
292 | msgstr ""
293 |
294 | #: lib/class_wdca_admin_form_renderer.php:384
295 | msgid "Normal"
296 | msgstr ""
297 |
298 | #: lib/class_wdca_admin_form_renderer.php:385
299 | msgid "Inline"
300 | msgstr ""
301 |
302 | #: lib/class_wdca_admin_form_renderer.php:386
303 | msgid "Dynamic"
304 | msgstr ""
305 |
306 | #: lib/class_wdca_admin_form_renderer.php:393
307 | msgid ""
308 | "This is where you can set up your A/B testing, and settings group loading "
309 | "rules."
310 | msgstr ""
311 |
312 | #: lib/class_wdca_admin_form_renderer.php:400
313 | msgid ""
314 | "By default, A/B mode distribution is random. Enabling this option will "
315 | "enforce initially selected mode for your users to persist accross requests "
316 | "(i.e. users that got A mode settings will keep seeing them, and vice versa)."
317 | msgstr ""
318 |
319 | #: lib/class_wdca_admin_form_renderer.php:415
320 | msgid ""
321 | "If A/B testing is enabled, allowing this option will let you test each group "
322 | "unconditionally, by passing this to your URL: ?wdca_mode=a for "
323 | "A group settings, ?wdca_mode=b for B group settings."
324 | msgstr ""
325 |
326 | #: lib/class_wdca_admin_pages.php:49 lib/class_wdca_admin_pages.php:121
327 | msgid "Settings"
328 | msgstr ""
329 |
330 | #: lib/class_wdca_admin_pages.php:51 lib/class_wdca_admin_pages.php:123
331 | msgid "Settings (A)"
332 | msgstr ""
333 |
334 | #: lib/class_wdca_admin_pages.php:52 lib/class_wdca_admin_pages.php:124
335 | msgid "Settings (B)"
336 | msgstr ""
337 |
338 | #: lib/class_wdca_admin_pages.php:54 lib/class_wdca_admin_pages.php:114
339 | msgid "A/B Settings"
340 | msgstr ""
341 |
342 | #: lib/class_wdca_admin_pages.php:63
343 | msgid "A/B mode setup"
344 | msgstr ""
345 |
346 | #: lib/class_wdca_admin_pages.php:64
347 | msgid "Enable A/B testing"
348 | msgstr ""
349 |
350 | #: lib/class_wdca_admin_pages.php:65
351 | msgid "Track mode in sessions"
352 | msgstr ""
353 |
354 | #: lib/class_wdca_admin_pages.php:66
355 | msgid "Always show B group to admins"
356 | msgstr ""
357 |
358 | #: lib/class_wdca_admin_pages.php:67
359 | msgid "Always show B group to all my users"
360 | msgstr ""
361 |
362 | #: lib/class_wdca_admin_pages.php:68
363 | msgid "GET key override"
364 | msgstr ""
365 |
366 | #: lib/class_wdca_admin_pages.php:81
367 | msgid "Custom Ads"
368 | msgstr ""
369 |
370 | #: lib/class_wdca_admin_pages.php:82
371 | msgid "Enable Custom Ads"
372 | msgstr ""
373 |
374 | #: lib/class_wdca_admin_pages.php:83
375 | msgid "Live mode"
376 | msgstr ""
377 |
378 | #: lib/class_wdca_admin_pages.php:84
379 | msgid "Show this many Ads"
380 | msgstr ""
381 |
382 | #: lib/class_wdca_admin_pages.php:85
383 | msgid "Order Ads by"
384 | msgstr ""
385 |
386 | #: lib/class_wdca_admin_pages.php:86
387 | msgid "Inject first Ad after this many paragraphs"
388 | msgstr ""
389 |
390 | #: lib/class_wdca_admin_pages.php:87
391 | msgid "Inject subsequent Ads after this many paragraphs each"
392 | msgstr ""
393 |
394 | #: lib/class_wdca_admin_pages.php:88
395 | msgid "Delayed Ads insertion"
396 | msgstr ""
397 |
398 | #: lib/class_wdca_admin_pages.php:89
399 | msgid "Predefined positions"
400 | msgstr ""
401 |
402 | #: lib/class_wdca_admin_pages.php:91
403 | msgid "Appearance & messages"
404 | msgstr ""
405 |
406 | #: lib/class_wdca_admin_pages.php:92
407 | msgid "Theme"
408 | msgstr ""
409 |
410 | #: lib/class_wdca_admin_pages.php:93
411 | msgid "Messages"
412 | msgstr ""
413 |
414 | #: lib/class_wdca_admin_pages.php:94
415 | msgid "Link click"
416 | msgstr ""
417 |
418 | #: lib/class_wdca_admin_pages.php:96
419 | msgid "Google Analytics Integration"
420 | msgstr ""
421 |
422 | #: lib/class_wdca_admin_pages.php:97
423 | msgid "Enable Google Analytics integration"
424 | msgstr ""
425 |
426 | #: lib/class_wdca_admin_pages.php:98
427 | msgid "Event category"
428 | msgstr ""
429 |
430 | #: lib/class_wdca_admin_pages.php:99
431 | msgid "Event label"
432 | msgstr ""
433 |
434 | #: lib/class_wdca_admin_pages.php:101
435 | msgid "Advanced"
436 | msgstr ""
437 |
438 | #: lib/class_wdca_admin_pages.php:102
439 | msgid "Custom post types Ads"
440 | msgstr ""
441 |
442 | #: lib/class_wdca_admin_pages.php:103
443 | msgid "Show post metabox"
444 | msgstr ""
445 |
446 | #: lib/class_wdca_admin_pages.php:104
447 | msgid "Connect post categories"
448 | msgstr ""
449 |
450 | #: lib/class_wdca_admin_pages.php:105
451 | msgid "Connect post tags"
452 | msgstr ""
453 |
454 | #: lib/class_wdca_admin_pages.php:106
455 | msgid "Elements selector"
456 | msgstr ""
457 |
458 | #: lib/class_wdca_admin_pages.php:107
459 | msgid "Lazy loading"
460 | msgstr ""
461 |
462 | #: lib/class_wdca_admin_pages.php:145
463 | msgid "Insert Ad"
464 | msgstr ""
465 |
466 | #: lib/class_wdca_admin_pages.php:148
467 | msgid "Appearance"
468 | msgstr ""
469 |
470 | #: lib/class_wdca_admin_pages.php:149
471 | msgid "Insert blank placeholder for an ad"
472 | msgstr ""
473 |
474 | #: lib/class_wdca_admin_pages.php:150
475 | msgid "or select an Ad to insert from the ones listed below"
476 | msgstr ""
477 |
478 | #: lib/class_wdca_admin_pages.php:152
479 | msgid "Size"
480 | msgstr ""
481 |
482 | #: lib/class_wdca_admin_pages.php:153
483 | msgid "Small"
484 | msgstr ""
485 |
486 | #: lib/class_wdca_admin_pages.php:154
487 | msgid "Medium"
488 | msgstr ""
489 |
490 | #: lib/class_wdca_admin_pages.php:155
491 | msgid "Large"
492 | msgstr ""
493 |
494 | #: lib/class_wdca_admin_pages.php:156
495 | msgid "Position"
496 | msgstr ""
497 |
498 | #: lib/class_wdca_admin_pages.php:157
499 | msgid "Left"
500 | msgstr ""
501 |
502 | #: lib/class_wdca_admin_pages.php:158
503 | msgid "Right"
504 | msgstr ""
505 |
506 | #: lib/class_wdca_admin_pages.php:168 lib/class_wdca_custom_ad.php:54
507 | msgid "In Post Ads"
508 | msgstr ""
509 |
510 | #: lib/class_wdca_admin_pages.php:186
511 | msgid "Do not show In Post Ads in this post"
512 | msgstr ""
513 |
514 | #: lib/class_wdca_custom_ad.php:55
515 | msgid "In Post Ad"
516 | msgstr ""
517 |
518 | #: lib/class_wdca_custom_ad.php:56
519 | msgid "Add new In Post Ad"
520 | msgstr ""
521 |
522 | #: lib/class_wdca_custom_ad.php:57
523 | msgid "Edit In Post Ad"
524 | msgstr ""
525 |
526 | #: lib/class_wdca_custom_ad.php:79 lib/class_wdca_custom_ad.php:100
527 | msgid "Ad Categories"
528 | msgstr ""
529 |
530 | #: lib/class_wdca_custom_ad.php:80
531 | msgid "Ad Category"
532 | msgstr ""
533 |
534 | #: lib/class_wdca_custom_ad.php:81
535 | msgid "Add new Ad Category"
536 | msgstr ""
537 |
538 | #: lib/class_wdca_custom_ad.php:82
539 | msgid "Edit Ad Category"
540 | msgstr ""
541 |
542 | #: lib/class_wdca_custom_ad.php:83
543 | msgid "Search Ad Categories"
544 | msgstr ""
545 |
546 | #: lib/class_wdca_custom_ad.php:84
547 | msgid "Popular Ad Categories"
548 | msgstr ""
549 |
550 | #: lib/class_wdca_custom_ad.php:85
551 | msgid "All Ad Categories"
552 | msgstr ""
553 |
554 | #: lib/class_wdca_custom_ad.php:86
555 | msgid "Separate Ad Categories with commas"
556 | msgstr ""
557 |
558 | #: lib/class_wdca_custom_ad.php:87
559 | msgid "Add or remove Ad Categories"
560 | msgstr ""
561 |
562 | #: lib/class_wdca_custom_ad.php:88
563 | msgid "Choose from most used Ad Categories"
564 | msgstr ""
565 |
566 | #: lib/class_wdca_custom_ad.php:113
567 | msgid "Ad link"
568 | msgstr ""
569 |
570 | #: lib/class_wdca_custom_ad.php:121
571 | msgid "Ad appearance"
572 | msgstr ""
573 |
574 | #: lib/class_wdca_custom_ad.php:132
575 | msgid "Link URL"
576 | msgstr ""
577 |
578 | #: lib/class_wdca_custom_ad.php:146
579 | msgid "Do not show title"
580 | msgstr ""
581 |
582 | #: lib/class_wdca_custom_ad.php:151
583 | msgid "Do not show content"
584 | msgstr ""
585 |
586 | #: lib/class_wdca_custom_ad.php:156
587 | msgid "Do not show footer"
588 | msgstr ""
589 |
590 | #: lib/class_wdca_custom_ad.php:161
591 | msgid "Strip default style"
592 | msgstr ""
593 |
--------------------------------------------------------------------------------
/lib/class_wdca_admin_form_renderer.php:
--------------------------------------------------------------------------------
1 | _mode_prefix = Wdca_Data::AB_MODE_KEY;
8 | else $this->_mode_prefix = Wdca_Data::get_valid_key($mode);
9 | }
10 |
11 | function _get_option ($key=false) {
12 | $opts = get_option($this->_mode_prefix);
13 | if (!$key) return $opts;
14 | return @$opts[$key];
15 | }
16 |
17 | function _create_checkbox ($name) {
18 | $pfx = $this->_mode_prefix;
19 | $opt = $this->_get_option($name);
20 | $value = @$opt[$name];
21 | return
22 | " " .
23 | "" .
24 | ' ' .
25 | " " .
26 | "" .
27 | "";
28 | }
29 |
30 | function _create_textbox ($name) {
31 | $pfx = $this->_mode_prefix;
32 | $value = (int)esc_attr($this->_get_option($name));
33 | return "";
34 | }
35 |
36 | function _create_text_inputbox ($name, $label, $help='', $pfx='wdca') {
37 | $pfx = $this->_mode_prefix;
38 | $value = esc_attr($this->_get_option($name));
39 | if ($help) $help = "0 to disable this behavior.', 'wdca') . '' . 198 | __('Note: your pages need to already be set up for Google Analytics tracking for this to work properly.', 'wdca') . 199 | '
'; 200 | } 201 | 202 | function create_ga_integration_box () { 203 | echo $this->_create_checkbox('ga_integration'); 204 | } 205 | 206 | function create_ga_category_box () { 207 | $value = $this->_get_option('ga_category'); 208 | $value = esc_attr(( 209 | $value 210 | ? $value 211 | : 'In Post Ads' 212 | )); 213 | echo ""; 214 | } 215 | 216 | function create_ga_label_box () { 217 | $value = $this->_get_option('ga_label'); 218 | if (!$value) $value = Wdca_Data::DEFAULT_KEY == $this->_mode_prefix ? 'Default' : 'Group B'; 219 | $value = esc_attr($value); 220 | echo ""; 221 | } 222 | 223 | function create_selector_box () { 224 | $selector = $this->_get_option('selector'); 225 | $selector = $selector ? $selector : '>p'; 226 | echo "" . 227 | 'p', 'wdca') . 'ul,ol,p', 'wdca') . '| ' . __('My posts within this Category', 'wdca') . '… | …' . __('will only show Ads from these Ad Categories', 'wdca') . ' |
|---|---|
| {$cat_str} | {$ad_str} |
| ' . __('My posts within this Tag', 'wdca') . '… | …' . __('will only show Ads from these Ad Categories', 'wdca') . ' |
|---|---|
| {$tag_str} | {$ad_str} |
' . 393 | __('This is where you can set up your A/B testing, and settings group loading rules.', 'wdca') . 394 | '
'; 395 | } 396 | 397 | function create_sessions_box () { 398 | echo $this->_create_checkbox('remember_in_session'); 399 | echo '?wdca_mode=a for A group settings, ?wdca_mode=b for B group settings.', 'wdca') .
416 | '