__('AdSense Revenue Share widget', 'ars_widget_domain'),) ); } public function widget($args, $instance) { $general_options = get_option('ars_settings'); $widget_options = $instance; $admin_pub = $general_options['ars_general_publisher_id']; $percent = $general_options['ars_general_percent']; if (is_single()) $post_id = $GLOBALS['post']->ID; if ($post_id) { $author_id = get_post($post_id)->post_author; $author_pub = get_the_author_meta('ars-publisher', $author_id); $author_percent = get_the_author_meta('ars-percent', $author_id); } if ($author_percent) $percent = $author_percent; if (empty($author_pub) || !preg_match('/pub-\d{16}/', $author_pub)) $author_pub = $admin_pub; list($width, $height) = explode('x', $widget_options['size']); $display_pub = (mt_rand(1, 100) <= $percent) ? $author_pub : $admin_pub; if (empty($display_pub) || !preg_match('/pub-\d{16}/', $display_pub)) $content = ''; else $content = '
'; $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; if (!empty($title)) echo $args['before_title'] . $title . $args['after_title']; echo $content; echo $args['after_widget']; } public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } else { $title = __('Advertisement', 'ars_widget_domain'); } $size = $instance['size']; ?>