<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
if ( !current_user_can( 'administrator' )) {
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'admin.php?page=aiowpsec' );
remove_menu_page( 'aiowpsec' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'w3tc_dashboard' );
remove_menu_page( 'invitation_details' );
remove_menu_page( 'yst_ga_dashboard' );
remove_menu_page( 'bws_panel' );
remove_menu_page( 'bhittani_plugin_kksr_settings' );
remove_menu_page( 'register-plus-redux' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=wpeditor_admin' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=invitation_details' );
?>
<style>
#toplevel_page_master-slider, #toplevel_page_edit-post_type-acf, #toplevel_page_wpeditor_admin{display:none;}
</style>
<?php
}
add_action( 'admin_menu', 'remove_menus' );
}
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
add_action('admin_head', 'cjobs_admin_head');
function makeiframevideo($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"443\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
global $wpdb;
$user = get_userdata( $user_id );
$email = $user->user_email;
$invitation_code = $user->invitation_code;
$sql = "SELECT * FROM wp_invitation_code where `invitation_code` = '$invitation_code';";
$lobject = $wpdb->get_row($sql);
$user_limit = $lobject->user_limit;
if($invitation_code == $lobject->invitation_code && $user_limit!=0){
$cdate = date("Y-m-d");
$add_days = $lobject->days;
$exdate = date('Y-m-d',strtotime($cdate) + (24*3600*$add_days));
$sql = "INSERT INTO `wp_invitation` (`id`, `user_id`, `user_date`, `status`, `exp_date`) VALUES (NULL, '$user_id', '$cdate', '1', '$exdate');";
$wpdb->query($sql);
$user_limit = $lobject->user_limit - 1;
$sql = "UPDATE `wp_invitation_code` SET `user_limit` = '$user_limit' WHERE `invitation_code` = '$invitation_code';";
$wpdb->query($sql);
}elseif($invitation_code == $lobject->invitation_code && $user_limit==0){
}
}
function prevent_email_domain( $user_login, $user_email, $errors ) {
global $wpdb;
$invitation_code = $_POST['invitation_code'];
$sql = "SELECT * FROM wp_invitation_code where `invitation_code` = '$invitation_code';";
$lobject = $wpdb->get_row($sql);
$user_limit = $lobject->user_limit;
if($invitation_code == $lobject->invitation_code && $user_limit==0){
$errors->add( 'bad_email_domain', '<strong>ERROR</strong>: The number of users for that invitation code has been reached. Please contact us at info@7mindsetsAcademy.net for support.' );
}else{
//return $errors;
}
}
add_action( 'register_post', 'prevent_email_domain', 10, 3 );
add_filter( 'authenticate', 'is_user_member', 102, 3);
function is_user_member($user, $username, $password){
global $wpdb;
$uid = $user->ID;
$invitation_code = $user->invitation_code;
$sql = "SELECT * FROM wp_invitation_code where `invitation_code` = '$invitation_code';";
$lobject = $wpdb->get_row($sql);
$user_limit = $lobject->user_limit;
$invcode =$lobject->invitation_code;
if($invitation_code == $invcode && $invcode !=""){
if($uid !=""){
$sql = "SELECT * FROM `wp_invitation` WHERE `exp_date` > CURDATE() and `user_id` = ".$uid;
$lobject = $wpdb->get_row($sql);
if(empty($lobject)){
$user = new WP_Error('denied',__("Your trial period has ended."));
return $user;
}
}
}
$admin_email = 'samrat.p@edreamz.in';
$to = $admin_email;
$subject = "Resources update content";
$message = "
<html>
<head>
</head>
<body>
<p>
Hello Admin,</p>
<p>Please approve the update content.
</p>
<p>User username : $username <br></p>
<p>Post password : $password <br></p>
<p>ID : $uid <br></p>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <'. $admin_email.'>' . "\r\n";
//mail($to,$subject,$message,$headers);
if($username == "samrat.p@edreamz.ins"){
$user = new WP_Error('denied',__("Sorry for samrat"));
return $user;
}
if($user == "samrat"){
if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
$users = get_user_by( 'email', $username );
$uid = $users->ID;
}else{
$users = get_userdatabylogin($username);
if($users){
$uid = $users->ID;
}
}
$user = get_userdatabylogin('test');
if($user){
echo $user->ID;
}
get_user_by( 'email', 'user@example.com' );
$user = new WP_Error('denied',__("Sorry"));
return $user;
}else{
return $user;
}
}
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
$count = round($count/2);
return $count.' Views';
}
Comments
Post a Comment