settings = new WordPressSettingsFramework(ARS_PATH_INCLUDES . '/settings/ars.php');
}
/**
* AdSense display filter
*/
public function adsense_display($content)
{
if (!is_single())
return $content;
$options = get_option('ars_settings');
if (!$options)
return $content;
if (!$options['ars_general_on'])
return $content;
$admin_pub = $options['ars_general_publisher_id'];
if (empty($admin_pub) || !preg_match('/pub-\d{16}/', $admin_pub))
return $content;
$author_pub = get_the_author_meta('ars-publisher');
if (empty($author_pub) || !preg_match('/pub-\d{16}/', $author_pub))
$author_pub = $admin_pub;
$percent = $options['ars_general_percent'];
$display_pub = (mt_rand(1, 100) <= $percent) ? $author_pub : $admin_pub;
list($width, $height) = explode('x', $options['ars_general_size']);
$ad_code = '
';
$position = $options['ars_general_position'];
switch ($position) {
case 'header':
$new_content = $ad_code . '
' . $content;
break;
case 'footer':
$new_content = $content . '
' . $ad_code;
break;
default:
$new_content = $content;
}
return $new_content;
}
/**
* Adding JavaScript scripts
*
* Loading existing scripts from wp-includes or adding custom ones
*/
public function ars_add_js()
{
}
/**
* Adding JavaScript scripts for the admin pages only
*
* Loading existing scripts from wp-includes or adding custom ones
*/
public function ars_add_admin_js()
{
}
/**
* Add CSS styles
*/
public function ars_add_css()
{
}
/**
* Add admin CSS styles - available only on admin
*/
public function ars_add_admin_css()
{
}
/**
* Callback for registering pages
*/
public function ars_admin_pages_callback()
{
add_options_page(__("Adsense Revenue Share", 'base'), __("Adsense Rev Share", 'base'), 'manage_options', 'ars-plugin-base', array($this, 'ars_settings'));
}
/**
* The content of the settings page
*/
public function ars_settings()
{
$this->settings->settings();
}
/**
* Add user extra meta fields
*/
public function ars_profile_fields($user)
{
?>
AdSense Information
Settings';
array_push($links, $settings_link);
return $links;
}
}
/**
* Register activation hook
*/
function ars_on_activate_callback()
{
}
/**
* Register deactivation hook
*/
function ars_on_deactivate_callback()
{
}
// Initialize plugin
$ars_plugin_base = new ARS_Plugin_Base();