Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/app-pixahive/wp-includes/functions.php on line 6131

Notice: Undefined index: host in /home/runcloud/webapps/app-pixahive/wp-content/plugins/quick-featured-images/admin/class-Quick_Featured_Images_Defaults.php on line 195

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the simple-tags domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/app-pixahive/wp-includes/functions.php on line 6131

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the updraftplus domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/app-pixahive/wp-includes/functions.php on line 6131

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the rocket domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/app-pixahive/wp-includes/functions.php on line 6131

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ultimate-member domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/runcloud/webapps/app-pixahive/wp-includes/functions.php on line 6131
"; //if old title contains jpg if (strpos($old_image_title, ".jpg") || strpos($old_image_title, ".jpeg")) : $suffix = "-".get_the_id()."-pixahive"; // -334343-pixahive $title_with_dash .= $suffix; //filename-334343-pixahive $new_image_title = $title_with_dash.".jpg"; //filename-334343-pixahive.jpg $new = str_replace($old_image_title, $new_image_title , $old); //To be used in renaming function $metadata = get_post_meta( get_post_thumbnail_id() , '_wp_attachment_metadata'); //get metadata, returns an array //print_r($metadata); $f1_name = $metadata[0]["file"]; //Name of the default file size $f1_new_name = str_replace($old_image_title, $new_image_title, $f1_name); $metadata[0]['file'] = $f1_new_name; //change default file name in metadata //All good, start renaming the main image if ( rename( $old, $new ) ) { update_post_meta( get_the_ID(), 'renamed', true ); } else { update_post_meta( get_the_ID(), 'rename-fail', true ); return; } //Handling the Thumbnail sizes now. MEDIUM if (array_key_exists('medium', $metadata[0]['sizes'])) : $med_f = $metadata[0]['sizes']['medium']['file']; $med_w = $metadata[0]['sizes']['medium']['width']; $med_h = $metadata[0]['sizes']['medium']['height']; $metadata[0]['sizes']['medium']['file'] = $title_with_dash."-".$med_w."x".$med_h.".jpg"; $old_med = $folder.$med_f; $new_med = $folder.$title_with_dash."-".$med_w."x".$med_h.".jpg"; if ( rename($old_med , $new_med) ) { //update_post_meta( get_the_ID(), 'renamed-medium', true ); } else { //update_post_meta( get_the_ID(), 'rename-med-fail', true ); } endif; //For Thumbnail if (array_key_exists('thumbnail', $metadata[0]['sizes'])) : $thb_f = $metadata[0]['sizes']['thumbnail']['file']; $thb_w = $metadata[0]['sizes']['thumbnail']['width']; $thb_h = $metadata[0]['sizes']['thumbnail']['height']; $metadata[0]['sizes']['thumbnail']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg"; $old_thb = $folder.$thb_f; $new_thb = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg"; //begin renaming if ( rename($old_thb, $new_thb) ) { //echo "successful thumbnail"; //update_post_meta( get_the_ID(), 'rename-thumbnail', true ); } else { //update_post_meta( get_the_ID(), 'rename-thumb-fail', true ); } endif; //For Large if (array_key_exists('large', $metadata[0]['sizes'])) : $thb_f = $metadata[0]['sizes']['large']['file']; $thb_w = $metadata[0]['sizes']['large']['width']; $thb_h = $metadata[0]['sizes']['large']['height']; $metadata[0]['sizes']['large']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg"; $old_large = $folder.$thb_f; $new_large = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg"; //begin renaming if ( rename($old_large, $new_large) ) { //update_post_meta( get_the_ID(), 'rename-large', true ); } else { //update_post_meta( get_the_ID(), 'rename-large-fail', true ); } endif; //For Large if (array_key_exists('medium_large', $metadata[0]['sizes'])) : $thb_f = $metadata[0]['sizes']['medium_large']['file']; $thb_w = $metadata[0]['sizes']['medium_large']['width']; $thb_h = $metadata[0]['sizes']['medium_large']['height']; $metadata[0]['sizes']['medium_large']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg"; $old_m_large = $folder.$thb_f; $new_m_large = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg"; //begin renaming if ( rename($old_m_large, $new_m_large) ) { //update_post_meta( get_the_ID(), 'rename-med_large', true ); } else { //update_post_meta( get_the_ID(), 'rename-med_large-fail', true ); } endif; if (array_key_exists('original_image', $metadata[0])) { $original_old = $folder.$metadata[0]['original_image']; $original_new = $folder.$title_with_dash."-original.jpg"; $metadata[0]['original_image'] = $title_with_dash."-original.jpg"; if ( rename($original_old, $original_new) ) { //update_post_meta( get_the_ID(), 'rename-original', true ); } else { //update_post_meta( get_the_ID(), 'rename-original-fail', true ); } } //print_r($metadata); update_post_meta( $thumb_id, '_wp_attached_file', $f1_new_name); update_post_meta( $thumb_id, '_wp_attachment_metadata', $metadata[0] ); endif; //check if image was jpeg or jpg } add_action('save_post_download','rename_media_file'); function rename_media_file_id( $postid ) { //global $post; //setup_postdata($postid); //check if file is already renamed , in preview or doing autosave //echo "HHHH".$postid; if (!isset($_GET['fren']) && (get_post_meta( $postid, 'renamed'))) { return; } if (is_preview()) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } $title = strip_tags(get_the_title($postid)); $thumb_id = get_post_thumbnail_id($postid); // Thumbnail id for updating thumbnail meta $old = get_attached_file($thumb_id); // full path of old file if (!file_exists($old)) { update_post_meta( $postid, 'renamed', 'filenotexists'); return; } //Sanitise file name $title = str_replace("@", "at", $title); $title = str_replace(array("&", "&"), "and", $title); $title = str_replace(array(" – "," –","– "), "-", $title); $title = str_replace(array(" ", " "), "", $title); $title = preg_replace('/[^a-zA-Z0-9_ -]/s','',$title); //$title = preg_replace('/[^A-Za-z0-9\-]/', '', $title); $title_with_dash = str_replace(" ", "-", $title); //get the title of post with dashes in between $old_image_title = basename($old); //complete file name with extension could be jpeg or jpeg $folder = str_replace($old_image_title, "", $old); //folder is where the file is present, contains the slash //echo "
";
	//if old title contains jpg
	if (strpos($old_image_title, ".jpg") || strpos($old_image_title, ".jpeg")) :
			
			
			
			$suffix = "-".$postid."-pixahive"; // -334343-pixahive
			$title_with_dash .= $suffix; //filename-334343-pixahive
			
			$new_image_title = $title_with_dash.".jpg"; //filename-334343-pixahive.jpg
			$new = str_replace($old_image_title, $new_image_title , $old); //To be used in renaming function
			
			$metadata = get_post_meta( get_post_thumbnail_id($postid) , '_wp_attachment_metadata'); //get metadata, returns an array
			
			//print_r($metadata);
			$f1_name = $metadata[0]["file"]; //Name of the default file size
			$f1_new_name = str_replace($old_image_title, $new_image_title, $f1_name);
			$metadata[0]['file'] = $f1_new_name; //change default file name in metadata
			
			
			
			//All good, start renaming the main image
			if ( rename( $old, $new ) ) {
					update_post_meta( $postid, 'renamed', true );
			} else {
				update_post_meta( $postid, 'rename-fail', true );
				return;
			}
			
			
			//Handling the Thumbnail sizes now. MEDIUM
			if (array_key_exists('medium', $metadata[0]['sizes'])) :
				$med_f = $metadata[0]['sizes']['medium']['file'];
				$med_w = $metadata[0]['sizes']['medium']['width'];
				$med_h = $metadata[0]['sizes']['medium']['height'];
				
				$metadata[0]['sizes']['medium']['file'] = $title_with_dash."-".$med_w."x".$med_h.".jpg";
				
				 $old_med = $folder.$med_f;
				 $new_med = $folder.$title_with_dash."-".$med_w."x".$med_h.".jpg";
				
				if ( rename($old_med , $new_med) ) {
						//update_post_meta( get_the_ID(), 'renamed-medium', true );
				} else {
					//update_post_meta( get_the_ID(), 'rename-med-fail', true );
				}
			endif; 
			
			
			
			//For Thumbnail
			if (array_key_exists('thumbnail', $metadata[0]['sizes'])) :
				$thb_f = $metadata[0]['sizes']['thumbnail']['file'];
				$thb_w = $metadata[0]['sizes']['thumbnail']['width'];
				$thb_h = $metadata[0]['sizes']['thumbnail']['height'];
			
				$metadata[0]['sizes']['thumbnail']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				 $old_thb = $folder.$thb_f;
				 $new_thb = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				//begin renaming
				if ( rename($old_thb, $new_thb) ) {
					//echo "successful thumbnail";
						//update_post_meta( get_the_ID(), 'rename-thumbnail', true );
				} else {
					//update_post_meta( get_the_ID(), 'rename-thumb-fail', true );
				}
			endif;
			
			//For Large
			if (array_key_exists('large', $metadata[0]['sizes'])) :
				$thb_f = $metadata[0]['sizes']['large']['file'];
				$thb_w = $metadata[0]['sizes']['large']['width'];
				$thb_h = $metadata[0]['sizes']['large']['height'];
			
				$metadata[0]['sizes']['large']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				 $old_large = $folder.$thb_f;
				 $new_large = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				//begin renaming
				if ( rename($old_large, $new_large) ) {
						//update_post_meta( get_the_ID(), 'rename-large', true );
				} else {
					//update_post_meta( get_the_ID(), 'rename-large-fail', true );
				}		
			endif;
			
			//For Large
			if (array_key_exists('medium_large', $metadata[0]['sizes'])) :
				$thb_f = $metadata[0]['sizes']['medium_large']['file'];
				$thb_w = $metadata[0]['sizes']['medium_large']['width'];
				$thb_h = $metadata[0]['sizes']['medium_large']['height'];
			
				$metadata[0]['sizes']['medium_large']['file'] = $title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				 $old_m_large = $folder.$thb_f;
				 $new_m_large = $folder.$title_with_dash."-".$thb_w."x".$thb_h.".jpg";
				
				//begin renaming
				if ( rename($old_m_large, $new_m_large) ) {
						//update_post_meta( get_the_ID(), 'rename-med_large', true );
				} else {
					//update_post_meta( get_the_ID(), 'rename-med_large-fail', true );
				}		
			endif;
			
			
			if (array_key_exists('original_image', $metadata[0])) {
				$original_old = $folder.$metadata[0]['original_image'];
				$original_new = $folder.$title_with_dash."-original.jpg";
				$metadata[0]['original_image'] = $title_with_dash."-original.jpg";
				if ( rename($original_old, $original_new) ) {
						//update_post_meta( get_the_ID(), 'rename-original', true );
				} else {
					//update_post_meta( get_the_ID(), 'rename-original-fail', true );
				}	
			}
			
			//print_r($metadata);
			 
			update_post_meta( $thumb_id, '_wp_attached_file', $f1_new_name);
			update_post_meta( $thumb_id, '_wp_attachment_metadata', $metadata[0] );
	
	endif;	//check if image was jpeg or jpg	
	wp_reset_postdata();	
}Settings > Media.
    #I am using default sizes for this project.
    #check if g-recaptcha-response is set. It only be avalaible if totalDownloads >= 5
    if (isset($_POST['g-recaptcha-response'])) {
        #if g-recaptcha-response is set check if its empty
        if ($_POST['g-recaptcha-response'] === '') {
            #if its empty it means user didn't perform validation so will ask user to perform recaptcha validation
            echo 'norecaptcha';
            wp_die();
        }
        #if g-recaptcha-response is set and not empty then this code will execute to check if the recaptcha response is correct.
        $siteSecret = "6Lc57cgZAAAAAMJOf099E57i7b79iRuN-L_4CJft"; //insert your secret key here.
        #sending request to google servers to check g-recaptcha-response
        $recaptchaResponseJSON = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $siteSecret . '&response=' . $_POST['g-recaptcha-response']);
        $responseObj = json_decode($recaptchaResponseJSON);
        #if g-recaptcha-response is not validated from google servers then show error
        if (!$responseObj->success) {
            echo 'verificationFailed';
            wp_die();
        }
    }
    
    #this code will execute if there is no g-recaptcha-response or if g-recaptcha-response is validated
    $imageUrl;
    switch ($_POST['dsize']) {
        case 'low':
            $imageUrl = getFeaturedImageAndStartDownload('medium', $_POST['id']);
            break;
        case 'med':
            $imageUrl = getFeaturedImageAndStartDownload('medium_large', $_POST['id']);
            break;
        case 'high':
            $imageUrl = getFeaturedImageAndStartDownload('large', $_POST['id']);
            break;
        case 'v-high':
            $imageUrl = getFeaturedImageAndStartDownload('full', $_POST['id']);
            break;
        case 'logo-source':
        	$fileid = get_field('logo_file_url', $_POST['id']);		                       
        	$imageUrl = wp_get_attachment_url( $fileid[0] );   
        	break;
        default:
            break;
    }
    increaseDownloadCount($_POST['id']);
    echo $imageUrl;
    wp_die();
}

function getFeaturedImageAndStartDownload($quality, $postId) {
    return get_the_post_thumbnail_url($postId, $quality);
}

/*
function increaseDownloadCount($postId) {
    #check if downloads cookie exist.
    if (!isset($_COOKIE['downloadStats'])) {
        #if cookie doesn't exist then create new cookie with json array
        $downloadsArray = array(
            'totalDownloads' => 1,
            'downloadedImageIds' => array($postId)
        );
        setcookie('downloadStats', json_encode($downloadsArray), time() + 60 * 60 * 24 * 30, '/');
    } else {
        $downloadsArrayString = stripslashes($_COOKIE['downloadStats']);
        $downloadsArray = json_decode($downloadsArrayString, true);
        #check if postId for that image exist in cookie
        #if it doesn't exist then add post id to downloadedImageIds array and update post_dl_count
        if (!in_array($postId, $downloadsArray['downloadedImageIds'])) {
            $downloadsArray['downloadedImageIds'][] = $postId;
            $downloadsArray['totalDownloads']++;
            #update cookie with new json array.
            setcookie('downloadStats', json_encode($downloadsArray), time() + 60 * 60 * 24 * 30, '/');
            #then get post_dl_count and increment it.
            $postDownloadCount = get_post_meta($postId, 'post_dl_count') ? get_post_meta($postId, 'post_dl_count') : 0;
            $postDownloadCount++;
            update_post_meta($postId, 'post_dl_count', $postDownloadCount);
        } else {
            #post id is already in cookie so don't update download count.
        }
    }
}
*/

function increaseDownloadCount($postId) {
    #check if downloads cookie exist.
    if (!isset($_COOKIE['downloadStats'])) {
        #if cookie doesn't exist then create new cookie with json array
        $downloadsArray = array(
            'totalDownloads' => 1,
            'downloadedImageIds' => array($postId)
        );
        setcookie('downloadStats', json_encode($downloadsArray), (time() + 60 * 60 * 24 * 30), '/');
    } else {
        $downloadsArrayString = stripslashes($_COOKIE['downloadStats']);
        $downloadsArray = json_decode($downloadsArrayString, true);
        #check if postId for that image exist in cookie
        #if it doesn't exist then add post id to downloadedImageIds array and update post_dl_count
        if (!in_array($postId, $downloadsArray['downloadedImageIds'])) {
            $downloadsArray['downloadedImageIds'][] = $postId;
            $downloadsArray['totalDownloads']++;
            #update cookie with new json array.
            setcookie('downloadStats', json_encode($downloadsArray), (time() + 60 * 60 * 24 * 30), '/');
            #then get post_dl_count and increment it.
            $postDownloadCount = get_post_meta($postId, 'post_dl_count') ? get_post_meta($postId, 'post_dl_count') : 0;
            $postDownloadCount++;
            update_post_meta($postId, 'post_dl_count', $postDownloadCount);
        } else {
            #post id is already in cookie so don't update download count.
        }
    }
}












	
	
	
	
	
	
	 'download',
					'author' => $user_id,
					'posts_per_page' => -1,
					'post_status' => array('publish','pending','trash','draft')
			));
			
			$image_id_array = array();
			if ($all_posts->have_posts())  {
				while ($all_posts->have_posts()) {
					$all_posts->the_post();
					if (has_post_thumbnail()) :
						array_push($image_id_array, get_post_thumbnail_id());
					endif;
					
				} //endwhile
				wp_reset_postdata();
			} //endif
			
			
			$args['author'] = $user_id;
			$args['post__not_in'] = $image_id_array;


			   return $args;		
	endif; //endif page check
} //functioncaps['subscriber'] ) ):
            add_filter('show_admin_bar', '__return_false');
        endif;
    endif;
}
add_action('init', 'disable_admin_bar_for_subscribers', 9);

function redirect_logged_in_users() {
	if (is_user_logged_in()) {
		if (is_page(array('login','register'))) {
			wp_safe_redirect( home_url()."/dashboard/" );
		}
	}
}
add_action( 'template_redirect', 'redirect_logged_in_users' );

function redirect_logged_out_users() {
	if (!is_user_logged_in()) {
		if (is_page(array('dashboard'))) {
			wp_safe_redirect( home_url()."/login/" );
		}
	}
}
add_action( 'template_redirect', 'redirect_logged_out_users' ); _x( 'Super Tags', 'Taxonomy General Name', 'mayosis' ),
		'singular_name'              => _x( 'Super Tag', 'Taxonomy Singular Name', 'mayosis' ),
		'menu_name'                  => __( 'Super Tag', 'mayosis' ),
		'all_items'                  => __( 'All Items', 'mayosis' ),
		'parent_item'                => __( 'Parent Item', 'mayosis' ),
		'parent_item_colon'          => __( 'Parent Item:', 'mayosis' ),
		'new_item_name'              => __( 'New Item Name', 'mayosis' ),
		'add_new_item'               => __( 'Add New Item', 'mayosis' ),
		'edit_item'                  => __( 'Edit Item', 'mayosis' ),
		'update_item'                => __( 'Update Item', 'mayosis' ),
		'view_item'                  => __( 'View Item', 'mayosis' ),
		'separate_items_with_commas' => __( 'Separate items with commas', 'mayosis' ),
		'add_or_remove_items'        => __( 'Add or remove items', 'mayosis' ),
		'choose_from_most_used'      => __( 'Choose from the most used', 'mayosis' ),
		'popular_items'              => __( 'Popular Items', 'mayosis' ),
		'search_items'               => __( 'Search Items', 'mayosis' ),
		'not_found'                  => __( 'Not Found', 'mayosis' ),
		'no_terms'                   => __( 'No items', 'mayosis' ),
		'items_list'                 => __( 'Items list', 'mayosis' ),
		'items_list_navigation'      => __( 'Items list navigation', 'mayosis' ),
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'rewrite'      				 => array('slug' => 'free-images', 'with_front' => false),
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
	);
	register_taxonomy( 'supertag', array( 'photo','logo','vector' ), $args );

}
add_action( 'init', 'super_tags', 0 );annotateImage($image, [
			    new Feature([
			        'type' => Type::LABEL_DETECTION,
			        'max_results' => 30
			    ])
			]);

			
			$labels = $response->getLabelAnnotations(); 
			
			$labels_string = "";
			$labels_array = array();
			$image_topicality = array();
			if ($labels) {
		    	$count = 0;
				
			    foreach ($labels as $label) {
					$score = $label->getScore() * 100;
					$image_topicality[$score] = $label->getDescription();
					
					$labels_string .= $label->getDescription().", ";
			
					if ($count < 4) {
						$labels_array[] = $label->getDescription();
					}
					
			
					$count++;
			    }
				
				update_post_meta($post_id, 'image_topicality', $image_topicality);
				update_field('vision_labels_string', $labels_string, $post_id);
				update_field("labels_set", true, $post_id);
				//wp_set_post_terms($post_id, $labels_array, 'download_tag', true);

			} else {
			    //echo('No label found' . PHP_EOL);
				update_field("labels_set", true, $post_id);
			}
	
			
/*
			TO BE ENABLED IN FUTURE - AI CAUSING SLOW SPEED in BACKEND, this functino is directly called in photo meta file
			wp_update_post(array(
				'ID' => $post_id,
				'post_content' => $labels_string
			));
*/
			
		else:
			update_field('vision_processing_failed', true, $post_id);
		endif; // file exists				
		
	endif; //label set
}

function remove_jetpack_image_downsize() {
    global $post;
    if (is_page(array(23293,235392,24681))) 
    	return true; 
    else 
    	return false;
}
add_filter('jetpack_photon_override_image_downsize', 'remove_jetpack_image_downsize');


function display_tag_suggestions($post_id) {
	
		
		$thim = get_post_thumbnail_id($post_id);
		$large_size = wp_get_attachment_image_src($thim, 'medium_large');
		$large_image = $large_size[0];
		//echo $large_image;
		
		
		
		$large_image = str_replace("https://pixahive.com/wp-content", "/srv/users/serverpilot/apps/pixahive/public/wp-content", $large_image);
		
		//echo $large_image;
		
		//echo $large_image;
		if (file_exists($large_image)) :
			$imageAnnotator = new ImageAnnotatorClient();
			$fileName = $large_image; //passed via param
		
			$image = file_get_contents($fileName);


			//Get 20 Labels
			$response = $imageAnnotator->annotateImage($image, [
			    new Feature([
			        'type' => Type::LABEL_DETECTION,
			        'max_results' => 30
			    ])
			]);

			
			$labels = $response->getLabelAnnotations(); 
			
			foreach ($labels as $label) {
				echo "
".$label->getDescription()."
"; } else : echo "

The AI could not find any tags

"; endif; } helper->get_option( 'fes-vendor-page', false ); // // if ( is_page('portfolio') ) { //vendor page // // $store_name = get_user_meta( $vendor->ID, 'name_of_store', true ); // //var_dump($store_name); // if ( empty( $store_name ) ) { // $vendor_name = EDD_FES()->helper->get_vendor_constant_name( $plural = false, $uppercase = true ) . ' ' . $vendor->display_name; // $title = sprintf( __('%s - View Portoflio','edd_fes'), $vendor_name ); // if (is_paged()) { // $title = $title." | Page ".get_query_var('paged'); // } // } else { // $title = $store_name ." - View Portfolio " ; // if (is_paged()) { // $title = $title." | Page ".get_query_var('paged'); // } // } // } // // return $title; // } // add_filter('wpseo_title', 'filter_portfolio_wpseo_title'); add_filter('wpseo_title','photo_page_title'); function photo_page_title($title) { global $wp_query; if( ! is_object( $wp_query ) ) { return false; } if (get_post_type() == 'download') { $title = get_the_title(); global $post; $author_id = $post->post_author; $author = get_the_author_meta('display_name', $author_id); $title = $title." - Free Image by ".$author. " on PixaHive.com"; } return $title; } add_filter('wpseo_metadesc','photo_meta_desc'); function photo_meta_desc($desc) { global $wp_query; if( ! is_object( $wp_query ) ) { return false; } if (get_post_type() == 'download') { $supertags_list = get_the_terms( get_the_ID(), 'supertag' ); $superterms_string = join(' and ', wp_list_pluck($supertags_list, 'name')); $author_id = get_post_field( 'post_author', get_the_id() ); $author = get_the_author_meta( 'display_name', $author_id ); $desc = "Free High Resolution Photo of ". $superterms_string.". Image by ".$author.". Image ID = ".get_the_ID()."."; return $desc; } }get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $thumbnailId)); #if the image is only attached to 1 post and post_id = post $attachmentWithOtherPost = false; if (count($associatedImage) !== 1) { $attachmentWithOtherPost = true; } #check if that image is associated with user_meta $attachmentWithUserMeta = false; $thumbnailUrl = get_the_post_thumbnail_url($postId, 'full'); $userAvatar = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_key LIKE '%user_avatar%' AND meta_value = %s", $thumbnailUrl)); if (count($userAvatar) !== 0) { $attachmentWithUserMeta = true; } #check if that image is used in any post_content $attachmentWithPostContent = false; $imageInPost = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_content LIKE %s AND post_status = 'publish'", '%' . $thumbnailUrl . '%')); if (count($imageInPost) !== 0) { $attachmentWithPostContent = true; } if ($attachmentWithOtherPost || $attachmentWithUserMeta || $attachmentWithPostContent) { #if any condition from above 3 passes then don't delete image return; } else { #move original thumbnail image to wp-content/delete-images/ #Get path for image from url preg_match('/.*(\/wp\-content\/uploads\/\d+\/\d+\/.*)/', $thumbnailUrl, $match); if (count($match) > 0) { $imagePath = str_replace('//', '/', ABSPATH . $match[1]); } $imageInfo = pathinfo($imagePath); #move original image file to wp-content/delete-images/ rename($imagePath, ABSPATH . 'wp-content/delete-images/' . $imageInfo['basename']); #force delete attachment file and all its versions wp_delete_post($thumbnailId, true); } } } _x( 'rereview', 'post' ), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Rereview (%s)', 'Rereview (%s)' ), ) ); } add_action( 'init', 'wpb_custom_post_status' ); // Using jQuery to add it to post status dropdown add_action('admin_footer-post.php', 'wpb_append_post_status_list'); function wpb_append_post_status_list(){ global $post; $complete = ''; $label = ''; if($post->post_type == 'download'){ if($post->post_status == 'rereview'){ $complete = ' selected="selected"'; $label = 'ReReview'; } echo ' '; } } _x( 'noimage', 'post' ), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'noimage (%s)', 'noimage (%s)' ), ) ); } add_action( 'init', 'noimage_custom_post_status' ); // Using jQuery to add it to post status dropdown add_action('admin_footer-post.php', 'noimage_append_post_status_list'); function noimage_append_post_status_list(){ global $post; $complete = ''; $label = ''; if($post->post_type == 'download'){ if($post->post_status == 'noimage'){ $complete = ' selected="selected"'; $label = 'noimage'; } echo ' '; } }
Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in /home/runcloud/webapps/app-pixahive/wp-content/themes/hive/taxonomy-download_tag.php on line 75

Fatal error: Exception thrown without a stack frame in Unknown on line 0