OwlCyberSecurity - MANAGER
Edit File: profile_aioseo.json
{"categories":[{"name":"AIOSEO Team","slug":"aioseo"}],"snippets":[{"library_id":17299,"title":"Add author name to article schema if its missing","code":"add_filter( 'aioseo_schema_output', 'add_author_name_when_missing' );\r\nfunction add_author_name_when_missing( $schema ) {\t\r\n\tif ( is_single() && 'post' == get_post_type() ) {\r\n\t\tglobal $post;\r\n\t\t$author_id = $post->post_author;\r\n\t\t$author_name = get_the_author_meta( 'display_name', $author_id );\r\n\r\n\t\tforeach ( $schema as &$schemaItem ) {\r\n\t\t\tif ( isset($schemaItem['@type']) && 'Article' === $schemaItem['@type'] ) {\r\n\t\t\t\tif(!isset($schemaItem['author']['name']) || !isset($schemaItem['author']['@type'])){\r\n\t\t\t\t\t$schemaItem['author']['@type'] = 'Person';\r\n\t\t\t\t\t$schemaItem['author']['name'] = $author_name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn $schema;\r\n}","note":"This snippet adds the author's name and author schema type to the article schema if...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":19824,"title":"Add deliveryTime schema to shippingDetails schema","code":"add_filter( 'aioseo_schema_output', function ( $schema ) {\r\n foreach ( $schema as &$schemaItem ) {\r\n if ( isset( $schemaItem['@type'] ) && 'Product' === $schemaItem['@type'] ) {\r\n\t\t\tif(!empty($schemaItem[\"offers\"][\"shippingDetails\"])){\r\n\t\t\t\t\/\/ Loop inside the Offers > shippingDetails schema\r\n\t\t\t\tforeach( $schemaItem[\"offers\"][\"shippingDetails\"] as &$schemaItemChild ){\r\n\t\t\t\t\/\/ Check for OfferShippingDetails schema where we need to add the deliveryTime schema\r\n\t\t\t\tif( isset( $schemaItemChild['@type'] ) && 'OfferShippingDetails' === $schemaItemChild['@type'] ){\r\n\t\t\t\t\t\/\/ Adding the deliveryTime schema\r\n\t\t\t\t\t$schemaItemChild[\"deliveryTime\"] = [\r\n\t\t\t\t\t\t\"@type\" => \"ShippingDeliveryTime\",\r\n\t\t\t\t\t\t\"handlingTime\" => [\r\n\t\t\t\t\t\t\t\"@type\" => \"QuantitativeValue\",\r\n\t\t\t\t\t\t\t\"minValue\" => 1,\r\n\t\t\t\t\t\t\t\"maxValue\" => 2,\r\n\t\t\t\t\t\t\t\"unitCode\" => \"d\"\r\n\t\t\t\t\t\t],\r\n\t\t\t\t\t\t\"transitTime\" => [\r\n\t\t\t\t\t\t\t\"@type\" => \"QuantitativeValue\",\r\n\t\t\t\t\t\t\t\"minValue\" => 1,\r\n\t\t\t\t\t\t\t\"maxValue\" => 3,\r\n\t\t\t\t\t\t\t\"unitCode\" => \"d\"\r\n\t\t\t\t\t\t]\r\n\t\t\t\t\t];\r\n\t\t\t\t}\r\n\t\t\t}\t\t\r\n\t\t\t}\t\r\n }\r\n }\r\n\r\n return $schema;\r\n}, 10, 2 );","note":"This snippet adds deliveryTime schema to shippingDetails schema that's present inside the Product > Offers...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17768,"title":"Add missing mainEntity to ProfilePage Schema","code":"add_filter( 'aioseo_schema_output', function ( $schema ) {\r\n\tforeach ( $schema as &$schemaItem ) {\r\n\t\tif (\r\n\t\t\tempty( $schemaItem['mainEntity'] ) &&\r\n\t\t\tisset( $schemaItem['@type'] ) &&\r\n\t\t\t'ProfilePage' === $schemaItem['@type']\r\n\t\t) {\r\n\t\t\tglobal $wp;\r\n\r\n\t\t\t$current_url = untrailingslashit( home_url( $wp->request ) );\r\n\t\t\t$schemaItem['mainEntity'] = [\r\n\t\t\t\t'@id' => $current_url . '\/#author'\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\r\n\treturn $schema;\r\n} );","note":"This snippet adds missing mainEntity to ProfilePage Schema","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17615,"title":"Add the type property to that Image property in the Organization schema","code":"add_filter( 'aioseo_schema_output', 'add_author_name_when_missing' );\r\nfunction add_author_name_when_missing( $schema ) {\t\r\n\t\tforeach ( $schema as &$schemaItem ) {\r\n\t\t\tif ( isset($schemaItem['@type']) && 'Organization' === $schemaItem['@type'] ) {\r\n\t\t\t\tif(!isset($schemaItem['image']['@type'])){\r\n\t\t\t\t\t$schemaItem['image']['@type'] = 'ImageObject';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\treturn $schema;\r\n}","note":"This snippet will add the 'ImageObject' type property in the 'Organization' schema markup.","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17103,"title":"AIOSEO - Increase SEO Analyzer TimeOut","code":"add_filter( 'http_request_args', 'aioseo_filter_analyzer_timeout', 1, 2 );\r\n\r\nfunction aioseo_filter_analyzer_timeout( $args, $url ) {\r\n\r\nif ( 'https:\/\/analyze.aioseo.com\/v1\/analyze\/' === $url ) {\r\n\r\n$args['timeout'] = 120;\r\n\r\n}\r\n\r\nreturn $args;\r\n\r\n}","note":"This snippet will increase the Timeout limit set for the SEO Analysis feature on a...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":16995,"title":"Change Schema Type of All Posts in Specific Categories","code":"add_filter('aioseo_schema_output', 'change_schema_type_in_specific_categories');\r\n\r\nfunction change_schema_type_in_specific_categories($schema) {\r\n \/\/ Specify the category slugs you want to target\r\n $target_category_slugs = array('category1-slug', 'category2-slug', 'category3-slug');\r\n\r\n foreach ($schema as &$schemaItem) {\r\n \/\/ Check if the post belongs to any of the specified categories\r\n if (isset($schemaItem['@type']) && 'NewsArticle' === $schemaItem['@type'] && has_category($target_category_slugs)) {\r\n $schemaItem['@type'] = 'Article';\r\n\t\t\tunset($schemaItem['dateline']);\r\n }\r\n }\r\n\r\n return $schema;\r\n}","note":"This snippet changes the 'NewsArticle' schema of all posts under specific categories to 'Article' schema....","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2343,"title":"Disable autogenerated shipping details schema for WooCommerce","code":"add_filter( 'aioseo_schema_woocommerce_shipping_disable', '__return_true' );","note":"This code snippet will disable AIOSEO autogenerated shipping details schema for WooCommerce Products","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2110,"title":"Disable SEO Preview feature","code":"add_action( 'init', function() {\r\n\tif ( ! function_exists( 'aioseo' ) ) {\r\n\t\treturn;\r\n\t}\r\n remove_action( 'wp', [ aioseo()->standalone->seoPreview, 'init' ] );\r\n}, 100);","note":"This code snippet can be used to remove the \"SEO Preview\" feature in All in...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":1994,"title":"Disable Shortcode Parsing in All in One SEO","code":"add_filter( 'aioseo_disable_shortcode_parsing', '__return_true' );","note":"This filter can be used to prevent AIOSEO from parsing shortcodes.","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":1893,"title":"Enable WooCommerce Product Attributes in Search Appearance","code":"add_filter( 'aioseo_woocommerce_product_attributes', '__return_true' );","note":"By default, AIOSEO does not include support for WooCommerce Product Attributes in our Search Appearance...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2276,"title":"Fix LearnPress conflict that hides AIOSEO tabs on settings pages","code":"add_filter( 'learnpress\/admin\/can-load-assets\/lp-admin', 'aioseoDontLoadLearnPress', 10, 2 );\r\nadd_filter( 'learnpress\/admin\/can-load-assets\/lp-admin-notice', 'aioseoDontLoadLearnPress', 10, 2 );\r\nfunction aioseoDontLoadLearnPress( $canLoad, $currentPage ) {\r\n\tif ( false === strpos( $currentPage, 'aioseo' ) ) {\r\n\t\treturn $canLoad;\r\n\t}\r\n\r\n\treturn false;\r\n}","note":"LearnPress hides the tabs of AIOSEO by loading its Vue assets on our pages. This...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2366,"title":"Limit Meta Description to 160 characters","code":"add_filter( 'aioseo_description', 'aioseo_filter_description' );\r\nfunction aioseo_filter_description( $description ) {\r\n if ( strlen($description) > 160 ) {\r\n $description = substr($description, 0, 159);\r\n }\r\n return $description;\r\n}","note":"This filter limits the Meta Description to 160 characters throughout the website","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2365,"title":"Limit SEO Title to 60 characters","code":"add_filter( 'aioseo_title', 'aioseo_filter_title' );\r\nfunction aioseo_filter_title( $title ) {\r\n if ( strlen($title) > 60 ) {\r\n $title = substr($title, 0, 60);\r\n }\r\n return $title;\r\n}","note":"This filter limits the SEO Title length to 60 characters throughout the website","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":1995,"title":"Noindex Product Search Pages","code":"add_filter( 'aioseo_robots_meta', 'aioseo_filter_robots_meta' );\r\nfunction aioseo_filter_robots_meta( $attributes ) {\r\n\tif ( is_search() && 'product' === get_query_var('post_type') ) {\r\n\t\t$attributes['index'] = \"noindex\";\r\n\t};\r\n\treturn $attributes;\r\n}","note":"This code snippet can be used to set noindex on WooCommerce product search pages.","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2134,"title":"Noindex Products under a Product Category","code":"add_filter( 'aioseo_robots_meta', 'aioseo_filter_robots_meta' );\r\n\r\nfunction aioseo_filter_robots_meta( $attributes ) {\r\n\tif ( has_term( 'CategoryName', 'product_cat' ) ) {\r\n\t\t$attributes['noindex'] = 'noindex';\r\n\t}\r\n\treturn $attributes;\r\n}","note":"This code snippet can be used to set noindex on all the Products under a...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2344,"title":"Recreate the aioseo_cache table","code":"add_action( 'init', function() {\r\n\tif ( function_exists( 'aioseo' ) ) {\r\n\t\taioseo()->preUpdates->createCacheTable();\r\n\t}\r\n});","note":"This code snippet recreates the missing 'aioseo_cache' table. This code snippet should be enabled and...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":15591,"title":"Remove #listItem from Breadcrumb schema","code":"add_filter('aioseo_schema_output', 'aioseo_schema_remove_list_item');\r\n\r\n\/\/ Callback function to remove '#listItem' from URLs in BreadcrumbList\r\nfunction aioseo_schema_remove_list_item($graphs) {\r\n \/\/ Loop through each element in the array\r\n foreach ($graphs as $index => $value) {\r\n \/\/ Check if the key '@type' is set and its value is 'BreadcrumbList'\r\n if (isset($value['@type']) && $value['@type'] === 'BreadcrumbList') {\r\n \/\/ Call the recursive function to remove '#listItem' from BreadcrumbList\r\n $graphs[$index] = aioseo_recursive_remove_list_item($value);\r\n }\r\n }\r\n\r\n return $graphs;\r\n}\r\n\r\n\/\/ Recursive function to traverse the array and remove '#listItem'\r\nfunction aioseo_recursive_remove_list_item($array) {\r\n \/\/ Loop through each element in the array\r\n foreach ($array as $key => &$value) {\r\n \/\/ If the element is an array, recursively call the function\r\n if (is_array($value)) {\r\n $value = aioseo_recursive_remove_list_item($value);\r\n }\r\n \/\/ If the element is a string and contains '#listItem', remove it\r\n elseif (is_string($value) && strpos($value, '#listItem') !== false) {\r\n $value = rtrim($value, '#listItem');\r\n }\r\n }\r\n\r\n return $array;\r\n}","note":"This snippet removes #listItem from all the URLs in the Breadcrumb schema","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":5807,"title":"Remove AggregateRating and Reviews Schema","code":"add_filter( 'aioseo_schema_output', 'product_schema_aggregate_reviews' );\r\nfunction product_schema_aggregate_reviews( $schema ) {\r\n\tforeach ( $schema as &$schemaItem ) {\r\n\t\tif ( 'Product' === $schemaItem['@type'] ) {\r\n\t\t\tunset ($schemaItem['aggregateRating']);\r\n\t\t\tunset ($schemaItem['review']);\r\n\t\t}\r\n\t}\r\n\r\n\treturn $schema;\r\n}","note":"This filter code removes the AggregateRating and Reviews Schemas","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17801,"title":"Remove Author Schema entirely from the website","code":"add_filter( 'aioseo_schema_output', 'add_author_name_when_missing' );\r\nfunction add_author_name_when_missing( $schema ) {\t\r\n\tforeach ( $schema as &$schemaItem ) {\r\n\t\tif ( isset($schemaItem['author']) ) {\r\n\t\t\tunset($schemaItem['author']);\r\n\t\t}\r\n\t}\r\n\treturn $schema;\r\n}","note":"This snippet removes Author Schema entirely from the website","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":20478,"title":"Remove BreadcrumbList Schema","code":"add_filter('aioseo_schema_output', 'aioseo_schema_remove_breadcrumblist_schema');\r\nfunction aioseo_schema_remove_breadcrumblist_schema($graphs) {\r\n foreach ($graphs as $index => $value) {\r\n if (isset($value['@type']) && $value['@type'] === 'BreadcrumbList') {\r\n\t\t\tunset($graphs[$index]);\r\n }\r\n } \r\n\treturn $graphs;\r\n}","note":"This snippet removes the BreadcrumbList Schema","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":3513,"title":"Remove SEO Statistics from the Dashboard menu","code":"add_action( 'admin_menu', 'aioseo_hide_search_stats_menu', 99999 );\r\n\r\nfunction aioseo_hide_search_stats_menu() {\r\n\tglobal $submenu;\r\n\tif ( ! isset( $submenu['index.php'] ) ) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tforeach ( $submenu['index.php'] as $index => $props ) {\r\n\t\tif ( ! empty( $props[2] ) && admin_url( '\/admin.php?page=aioseo-search-statistics' ) === $props[2] ) {\r\n\t\t\tunset( $submenu['index.php'][ $index ] );\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n}","note":"Code Snippet to remove SEO Statistics from the Dashboard menu","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2008,"title":"Remove the Canonical URL for a specific URL","code":"add_filter( 'aioseo_canonical_url', 'aioseo_filter_canonical_url' );\r\nfunction aioseo_filter_canonical_url( $url ) {\r\n\tif (strpos($url,'\/properties\/') !== false) {\r\n\t\t$url = home_url( $_SERVER['REQUEST_URI'] );\r\n\t}\r\n\treturn $url;\r\n}","note":"This code snippet can be used to remove the canonical URL for a specific URL...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2834,"title":"Scan images from Elementor Galleries and counts them for the sitemap XML","code":"add_filter(\r\n\t'aioseo_sitemap_images',\r\n\t\/**\r\n\t * Find new images inside the post content which has Elementor galleries.\r\n\t * It only works for self-hosted attachments.\r\n\t *\r\n\t * @param array $images The images already found.\r\n\t * @param object $post The post object\r\n\t * @return array All images merged with found images.\r\n\t *\/\r\n\tfunction ( $images, $post ) {\r\n\t\tif (\r\n\t\t\t! is_array( $images ) ||\r\n\t\t\t! is_object( $post ) ||\r\n\t\t\tempty( $post->ID ) ||\r\n\t\t\tempty( $post->post_content )\r\n\t\t) {\r\n\t\t\treturn $images;\r\n\t\t}\r\n\r\n\t\t\/\/ Bail if this post is not being edited under Elementor.\r\n\t\tif ( 'builder' !== get_post_meta( $post->ID, '_elementor_edit_mode', true ) ) {\r\n\t\t\treturn $images;\r\n\t\t}\r\n\r\n\t\tpreg_match_all( '\/<a.+?href=\"(http[^\"]+)\"\\s.+?lightbox.*?>\/i', $post->post_content, $matches );\r\n\r\n\t\tif ( empty( $matches[1] ) ) {\r\n\t\t\treturn $images;\r\n\t\t}\r\n\r\n\t\tforeach ( $matches[1] as $url ) {\r\n\t\t\t$url = wp_get_attachment_url( attachment_url_to_postid( $url ) );\r\n\t\t\tif ( $url ) {\r\n\t\t\t\t$images[] = $url;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn array_unique( $images );\r\n\t},\r\n\t10,\r\n\t2\r\n);","note":"This snippet will find new images inside the post content, which has Elementor Galleries. And...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":2382,"title":"Set current URL as the Canonical URL and ignore query strings","code":"add_filter( 'aioseo_canonical_url', 'aioseo_filter_canonical_url' );\r\nfunction aioseo_filter_canonical_url( $url ) {\r\n\tif (strpos($_SERVER['REQUEST_URI'],'\/home-search\/listing\/') !== false) {\r\n\t\t$url = home_url( $_SERVER['REQUEST_URI'] );\r\n\t\tif (strpos($url,'?') !== false){\r\n\t\t\t\t$url = substr( $url, 0, strpos($url,'?') );\r\n\t\t}\r\n\t}\r\n\treturn $url;\r\n}","note":"This snippet searches for a specific string in the current URL and if found, it...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17514,"title":"Set max-video-preview to 0","code":"add_filter( 'aioseo_robots_meta', 'aioseo_filter_robots_meta' );\r\n\r\nfunction aioseo_filter_robots_meta( $attributes ) {\r\n $attributes['max-video-preview'] = 'max-video-preview: 0';\r\n return $attributes;\r\n}","note":"This snippet sets max-video-preview robots meta tag to 0","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":16393,"title":"Shortcode to get all taxonomy values of current post","code":"function display_post_artists_shortcode() {\r\n \/\/ Get the terms (artists) of the \"artist\" taxonomy for the current post\r\n $artists = get_the_terms(get_the_ID(), 'artist');\r\n\r\n \/\/ Check if artists exist\r\n if ($artists && !is_wp_error($artists)) {\r\n \/\/ Start building the output\r\n $output = [];\r\n\r\n \/\/ Loop through each artist\r\n foreach ($artists as $artist) {\r\n \/\/ Generate a link to the artist archive\r\n $artist_link = get_term_link($artist);\r\n\r\n \/\/ Append each artist to the output\r\n $output[] = esc_html($artist->name);\r\n }\r\n\t\t\r\n\t\t\/\/ Merge the artist names with a comma separator\r\n\t\t$output = implode(', ', $output);\r\n\r\n return $output;\r\n }\r\n\r\n \/\/ Return an empty string if no artists are found\r\n return '';\r\n}\r\n\r\n\/\/ Register the shortcode\r\nadd_shortcode('post_artists', 'display_post_artists_shortcode');\r\n","note":"This snippet declares a shortcode to get all \"Artist\" taxonomy values of the current post.","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":17652,"title":"Show link assistant suggestions","code":"add_action('admin_head', 'show_link_assistant_suggestions');\r\n\r\nfunction show_link_assistant_suggestions() {\r\n echo '<style>\r\n .aioseo-tab-content.aioseo-link-assistant .wp-table .wp-list-table.widefat.fixed{\r\n\t position: unset !important;\r\n } \r\n <\/style>';\r\n}","note":"This snippet fixes a conflict of a custom theme with the default WordPress class called...","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""},{"library_id":13911,"title":"Showcase IDX plugin - Replace all Permalink URLs with current URL in Schema","code":"add_filter( 'aioseo_schema_output', 'aioseo_schema_change_urls' );\r\nfunction aioseo_schema_change_urls( $graphs ) {\r\n if ( false === strpos( $_SERVER['REQUEST_URI'], 'search-results\/listing\/' ) ) {\r\n return $graphs;\r\n }\r\n\t\r\n $request_uri = explode( '?', $_SERVER['REQUEST_URI'] );\r\n\t$request_uri = explode( '#', $request_uri[0] );\r\n $url_parts = trim($request_uri[0], '\/');\r\n $url_parts = explode('\/', $url_parts);\r\n $last_segment = end($url_parts);\r\n $old_url = get_permalink();\r\n $new_url = home_url( $request_uri[0] );\t\r\n\t\r\n foreach ( $graphs as $index => &$value ) {\r\n if ( is_array( $value ) ) {\r\n $value = aioseo_schema_change_urls( $value );\r\n }\r\n\r\n if ( is_string( $value ) ) {\r\n if ( $value === $old_url ) {\r\n $value = $new_url;\r\n } elseif ( false !== strpos( $value, $old_url . '#' ) ) {\r\n $value = str_replace( $old_url, $new_url, $value );\r\n }\r\n }\r\n\t\t\r\n }\r\n\r\n return $graphs;\r\n}","note":"This snippet replaces all the Permalink URLs with the current URL in Schema markup.","categories":["aioseo"],"code_type":"php","needs_auth":false,"max_version":""}]}