Sindbad~EG File Manager
<?php
/*
* Security : blocking direct access
* Source : http://codex.wordpress.org/Theme_Development#Template_Files
* Just Note for me : https://stackoverflow.com/a/40763344
*/
defined('ABSPATH') or die("Access Restricted");
/*
* Adsense - Revenu Share
*
* Add extra field to user profile
*
*/
add_action( 'show_user_profile', 'mwp_ars_profile_fields' );
add_action( 'edit_user_profile', 'mwp_ars_profile_fields' );
function mwp_ars_profile_fields( $user ) {
if ( current_user_can( 'publish_posts', $user ) ) {
?>
<h3><?php _e("Adsense - Revenu Share", MWP_TEXT_DOMAIN); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="mwp_ars_ad_client"><?php echo 'Adsense : data-ad-client'; ?></label>
</th>
<td>
<input type="text" name="mwp_ars_ad_client" id="mwp_ars_ad_client" value="<?php echo esc_attr( get_the_author_meta( 'mwp_ars_ad_client', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e("Please enter your ad client (ca-pub-xxxxxxxxxxxxxxxx)", MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
<tr>
<th>
<label for="mwp_ars_ad_slot"><?php echo 'Adsense : data-ad-slot'; ?></label>
</th>
<td>
<input type="text" name="mwp_ars_ad_slot" id="mwp_ars_ad_slot" value="<?php echo esc_attr( get_the_author_meta( 'mwp_ars_ad_slot', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e("Please enter your ad slot (1234567890)", MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
</table>
<h3><?php _e("Google Analytics", MWP_TEXT_DOMAIN); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="mwp_ars_ad_client"><?php _e("Tracking Code", MWP_TEXT_DOMAIN); ?></label>
</th>
<td>
<input type="text" name="mwp_ars_analytics" id="mwp_ars_analytics" value="<?php echo esc_attr( get_the_author_meta( 'mwp_ars_analytics', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e('Tracking Code Example : UA-00042521-6 <br> Follow the instructions in the following link <a target="_blank" href="https://store.mwordpress.net/google-analytics-documentation/">Google Analytics Documentation</a>', MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
</table>
<h3><?php _e("POSTQUARE ADS", MWP_TEXT_DOMAIN); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="mwp_prs_wid"><?php _e("POSTQUARE : wid", MWP_TEXT_DOMAIN); ?></label>
</th>
<td>
<input type="text" name="mwp_prs_wid" id="mwp_prs_wid" value="<?php echo esc_attr( get_the_author_meta( 'mwp_prs_wid', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e('POSTQUARE follow the instructions in the following link <a target="_blank" href="https://store.mwordpress.net/postquare-documentation/">POSTQUARE Documentation</a>', MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
<tr>
<th>
<label for="mwp_prs_pubid"><?php _e("POSTQUARE : pubid", MWP_TEXT_DOMAIN); ?></label>
</th>
<td>
<input type="text" name="mwp_prs_pubid" id="mwp_prs_pubid" value="<?php echo esc_attr( get_the_author_meta( 'mwp_prs_pubid', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e('POSTQUARE follow the instructions in the following link <a target="_blank" href="https://store.mwordpress.net/postquare-documentation/">POSTQUARE Documentation</a>', MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
<tr>
<th>
<label for="mwp_prs_webid"><?php _e("POSTQUARE : webid", MWP_TEXT_DOMAIN); ?></label>
</th>
<td>
<input type="text" name="mwp_prs_webid" id="mwp_prs_webid" value="<?php echo esc_attr( get_the_author_meta( 'mwp_prs_webid', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e('POSTQUARE follow the instructions in the following link <a target="_blank" href="https://store.mwordpress.net/postquare-documentation/">POSTQUARE Documentation</a>', MWP_TEXT_DOMAIN); ?></span>
</td>
</tr>
</table>
<?php
}
}
/*
* Adsense - Revenu Share
*
* Update field to user
*
*/
add_action( 'personal_options_update', 'save_mwp_ars_profile_fields' );
add_action( 'edit_user_profile_update', 'save_mwp_ars_profile_fields' );
function save_mwp_ars_profile_fields( $user_id ) {
if ( !current_user_can( 'publish_posts', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'mwp_ars_ad_client', $_POST['mwp_ars_ad_client'] );
update_user_meta( $user_id, 'mwp_ars_ad_slot', $_POST['mwp_ars_ad_slot'] );
update_user_meta( $user_id, 'mwp_ars_analytics', $_POST['mwp_ars_analytics'] );
update_user_meta( $user_id, 'mwp_prs_wid', $_POST['mwp_prs_wid'] );
update_user_meta( $user_id, 'mwp_prs_pubid', $_POST['mwp_prs_pubid'] );
update_user_meta( $user_id, 'mwp_prs_webid', $_POST['mwp_prs_webid'] );
}
/*
* Adsense - Revenu Share
*
* randomize the admin/author accordingly
*
*/
function mwp_ads_revenu_share($fixed=false, $ad_format=false) {
global $post;
$author_id = $post->post_author;
$get_percent = mwp_option('ars-admin-ad-percentage');
$admin_ad_client = mwp_option('ars-admin-ad-client');
$admin_ad_slot = mwp_option('ars-admin-ad-slot');
$author_ad_client = get_the_author_meta( 'mwp_ars_ad_client', $author_id );
$author_ad_slot = get_the_author_meta( 'mwp_ars_ad_slot', $author_id );
$check_authors_list = mwp_option('ars-select-author');
if (!empty($admin_ad_client) && !empty($admin_ad_slot)) {
if (!empty($get_percent)) {
$percent = $get_percent;
} else {
$percent = 50;
}
$ray_state = array_filter($check_authors_list);
// Here Only Select Authors Will Use Adsense Revenu Share
if (!empty($ray_state) && in_array($author_id, $check_authors_list)) {
// Ad Client check
if($author_ad_client != ""){
$input1 = $admin_ad_client;
$input2 = $author_ad_client;
} else {
$input1 = $admin_ad_client;
$input2 = $input1;
}
// Ad Slot check
if($author_ad_slot != ""){
$input3 = $admin_ad_slot;
$input4 = $author_ad_slot;
} else {
$input3 = $admin_ad_slot;
$input4 = $input3;
}
}
// Here will Skip Authors Not Select In Adsense Revenu Share
elseif (!empty($ray_state) && !in_array($author_id, $check_authors_list)) {
// Ad Client check
if($author_ad_client != ""){
$input1 = $admin_ad_client;
$input2 = $input1;
} else {
$input1 = $admin_ad_client;
$input2 = $input1;
}
// Ad Slot check
if($author_ad_slot != ""){
$input3 = $admin_ad_slot;
$input4 = $input3;
} else {
$input3 = $admin_ad_slot;
$input4 = $input3;
}
}
// Here All Authors Can Use Adsense Revenu Share
else {
// Ad Client check
if($author_ad_client != ""){
$input1 = $admin_ad_client;
$input2 = $author_ad_client;
} else {
$input1 = $admin_ad_client;
$input2 = $input1;
}
// Ad Slot Check
if($author_ad_slot != ""){
$input3 = $admin_ad_slot;
$input4 = $author_ad_slot;
} else {
$input3 = $admin_ad_slot;
$input4 = $input3;
}
}
srand(time());
$random = (rand()%101);
if ($random <= $percent) {
$ad_client = $input1;
$ad_slot = $input3;
} else {
$ad_client = $input2;
$ad_slot = $input4;
}
if ($fixed == 1) {
return mwp_ads_revenu_share_display_fixed($ad_client, $ad_slot);
} else {
return mwp_ads_revenu_share_display($ad_client, $ad_slot, $ad_format);
}
} else {
$text = __('Note: Revenu share is enabled for this ad unit <br> You must set "Adsense : data-ad-client" and "Adsense : data-ad-slot" from theme panel' , MWP_TEXT_DOMAIN);
return '<div style="color:red;border:1px solid red;width:100%;padding:20px;text-align:center;line-height:1.5;">'.$text.'</div>';
}
}
/*
* Adsense - Revenu Share
*
* check class and display code
*
*/
function mwp_ads_revenu_share_display($ad_client, $ad_slot, $ad_format) {
if (!empty($ad_format)) {
$format = $ad_format;
} else {
$format = 'auto';
}
if ($ad_format == 'fluid') {
$fluid_tag = 'data-ad-layout="in-article"';
} else {
$fluid_tag = '';
}
if(mwp_option('adsense-on-scroll') == 0) {
return '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
'.$fluid_tag.'
data-ad-format="'.$format.'"
data-ad-client="'.$ad_client.'"
data-ad-slot="'.$ad_slot.'"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
} else {
return '<ins class="adsbygoogle"
style="display:block"
data-ad-format="'.$format.'"
data-ad-client="'.$ad_client.'"
data-ad-slot="'.$ad_slot.'"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
}
}
/*
* Adsense - Revenu Share
*
* check class and display code
*
* Fixed ADS ==> 160px / 600px
*
*/
function mwp_ads_revenu_share_display_fixed($ad_client, $ad_slot) {
if(mwp_option('adsense-on-scroll') == 0) {
return '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:160px;height:600px;"
data-ad-client="'.$ad_client.'"
data-ad-slot="'.$ad_slot.'"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
} else {
return '<ins class="adsbygoogle"
style="display:inline-block;width:160px;height:600px;"
data-ad-client="'.$ad_client.'"
data-ad-slot="'.$ad_slot.'"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
}
}
/*
* POSTQUARE - Revenu Share
*
* randomize the admin/author accordingly
*
*/
function mwp_ads_rs_postquare() {
global $post;
$author_id = $post->post_author;
$get_percent = mwp_option('ars-admin-ad-percentage');
$admin_ad_prs_wid = mwp_option('mwp_admin_prs_wid');
$admin_ad_prs_pubid = mwp_option('mwp_admin_prs_pubid');
$admin_ad_prs_webid = mwp_option('mwp_admin_prs_webid');
$author_ad_prs_wid = get_the_author_meta( 'mwp_prs_wid', $author_id );
$author_ad_prs_pubid = get_the_author_meta( 'mwp_prs_pubid', $author_id );
$author_ad_prs_webid = get_the_author_meta( 'mwp_prs_webid', $author_id );
$check_authors_list = mwp_option('ars-select-author');
if (!empty($get_percent)) {
$percent = $get_percent;
} else {
$percent = 50;
}
$ray_state = array_filter($check_authors_list);
// Here Only Select Authors Will Use Adsense Revenu Share
if (!empty($ray_state) && in_array($author_id, $check_authors_list)) {
// wid check
if($author_ad_prs_wid != ""){
$input1 = $admin_ad_prs_wid;
$input2 = $author_ad_prs_wid;
} else {
$input1 = $admin_ad_prs_wid;
$input2 = $input1;
}
// pubid check
if($author_ad_prs_pubid != ""){
$input3 = $admin_ad_prs_pubid;
$input4 = $author_ad_prs_pubid;
} else {
$input3 = $admin_ad_prs_pubid;
$input4 = $input3;
}
// webid check
if($author_ad_prs_webid != ""){
$input5 = $admin_ad_prs_webid;
$input6 = $author_ad_prs_webid;
} else {
$input5 = $admin_ad_prs_webid;
$input6 = $input5;
}
}
// Here will Skip Authors Not Select In Adsense Revenu Share
elseif (!empty($ray_state) && !in_array($author_id, $check_authors_list)) {
// wid check
if($author_ad_prs_wid != ""){
$input1 = $admin_ad_prs_wid;
$input2 = $input1;
} else {
$input1 = $admin_ad_prs_wid;
$input2 = $input1;
}
// pubid check
if($author_ad_prs_pubid != ""){
$input3 = $admin_ad_prs_pubid;
$input4 = $input3;
} else {
$input3 = $admin_ad_prs_pubid;
$input4 = $input3;
}
// webid check
if($author_ad_prs_webid != ""){
$input5 = $admin_ad_prs_webid;
$input6 = $input5;
} else {
$input5 = $admin_ad_prs_webid;
$input6 = $input5;
}
}
// Here All Authors Can Use Adsense Revenu Share
else {
// wid check
if($author_ad_prs_wid != ""){
$input1 = $admin_ad_prs_wid;
$input2 = $author_ad_prs_wid;
} else {
$input1 = $admin_ad_prs_wid;
$input2 = $input1;
}
// pubid check
if($author_ad_prs_pubid != ""){
$input3 = $admin_ad_prs_pubid;
$input4 = $author_ad_prs_pubid;
} else {
$input3 = $admin_ad_prs_pubid;
$input4 = $input3;
}
// webid check
if($author_ad_prs_webid != ""){
$input5 = $admin_ad_prs_webid;
$input6 = $author_ad_prs_webid;
} else {
$input5 = $admin_ad_prs_webid;
$input6 = $input5;
}
}
srand(time());
$random = (rand()%101);
if ($random <= $percent) {
$ad_wid = $input1;
$ad_pubid = $input3;
$ad_webid = $input5;
} else {
$ad_wid = $input2;
$ad_pubid = $input4;
$ad_webid = $input6;
}
return mwp_ads_rs_postquare_code($ad_wid, $ad_pubid, $ad_webid);
}
/*
* POSTQUARE - Revenu Share
*
* check class and display code
*
*/
function mwp_ads_rs_postquare_code($ad_wid, $ad_pubid, $ad_webid) {
if(mwp_option('postquare-load-onscroll') == 1) {
return "<div id='POSTQUARE_WIDGET_$ad_wid'></div>
<script>
var pfired = false;
window.addEventListener('scroll', function(){
if ((document.documentElement.scrollTop != 0 && pfired === false) || (document.body.scrollTop != 0 && pfired === false)) {
(function(P,o,s,t,Q,r,e){P['PostquareObject']=Q;P[Q]=P[Q]||function(){ (P[Q].q=P[Q].q||[]).push(arguments)},P[Q].l=1*new Date();r=o.createElement(s), e=o.getElementsByTagName(s)[0];r.async=1;r.src=t;e.parentNode.insertBefore(r,e) })(window,document,'script','//widget.engageya.com/_pos_loader.js','__posWidget');
__posWidget('createWidget',{wwei:'POSTQUARE_WIDGET_$ad_wid',pubid:$ad_pubid,webid:$ad_webid,wid:$ad_wid,on:'postquare'});
pfired = true;
}
}, true)
</script>";
} else {
return "<div id='POSTQUARE_WIDGET_$ad_wid'></div>
<script>
(function(P,o,s,t,Q,r,e){P['PostquareObject']=Q;P[Q]=P[Q]||function(){ (P[Q].q=P[Q].q||[]).push(arguments)},P[Q].l=1*new Date();r=o.createElement(s), e=o.getElementsByTagName(s)[0];r.async=1;r.src=t;e.parentNode.insertBefore(r,e) })(window,document,'script','//widget.engageya.com/_pos_loader.js','__posWidget');
__posWidget('createWidget',{wwei:'POSTQUARE_WIDGET_$ad_wid',pubid:$ad_pubid,webid:$ad_webid,wid:$ad_wid,on:'postquare'});
</script>";
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists