static function deleteLogo() {

		check_ajax_referer( 'pb-delete-catalog-logo' );

		$image_url = $_POST['filename'];
		$user_id = (int) $_POST['pid'];

		$book = get_active_blog_for_user( $user_id );
		if ( current_user_can_for_blog( $book->blog_id, 'upload_files' ) ) {

			switch_to_blog( $book->blog_id );

			// Delete old images
			$old_id = \Pressbooks\Image\attachment_id_from_url( $image_url );
			if ( $old_id ) {
				wp_delete_attachment( $old_id, true );
			}

			update_user_meta( $user_id, 'pb_catalog_logo', \Pressbooks\Image\default_cover_url() );

			restore_current_blog();
		}

		// @see http://codex.wordpress.org/AJAX_in_Plugins#Error_Return_Values
		// Will append 0 to returned json string if we don't die()
		die();
	}
static function deleteLogo() {

		check_ajax_referer( 'pb-delete-catalog-logo' );

		$image_url = $_POST['filename'];
		$user_id = (int) $_POST['pid'];

		$book = get_active_blog_for_user( $user_id );
		if ( current_user_can_for_blog( $book->blog_id, 'upload_files' ) ) {

			switch_to_blog( $book->blog_id );

			// Delete old images
			$old_id = \Pressbooks\Image\attachment_id_from_url( $image_url );
			if ( $old_id ) {
				wp_delete_attachment( $old_id, true );
			}

			update_user_meta( $user_id, 'pb_catalog_logo', \Pressbooks\Image\default_cover_url() );

			restore_current_blog();
		}

		// @see http://codex.wordpress.org/AJAX_in_Plugins#Error_Return_Values
		// Will append 0 to returned json string if we don't die()
		die();
	}
static function deleteLogo ( ) { check_ajax_referer ( 'pb-delete-catalog-logo' ) ; $ image_url = $ _POST [ 'filename' ] ; $ user_id = ( int ) $ _POST [ 'pid' ] ; $ book = get_active_blog_for_user ( $ user_id ) ; if ( current_user_can_for_blog ( $ book -> blog_id , 'upload_files' ) ) { switch_to_blog ( $ book -> blog_id ) ; // Delete old images $ old_id = \ Pressbooks \ Image \ attachment_id_from_url ( $ image_url ) ; if ( $ old_id ) { wp_delete_attachment ( $ old_id , true ) ; } update_user_meta ( $ user_id , 'pb_catalog_logo' , \ Pressbooks \ Image \ default_cover_url ( ) ) ; restore_current_blog ( ) ; } // @see http://codex.wordpress.org/AJAX_in_Plugins#Error_Return_Values // Will append 0 to returned json string if we don't die() die ( ) ; }
WP_Ajax hook for pb_delete_catalog_logo
WP_Ajax hook for pb_delete_catalog_logo