/** * Regenerate Thumbnails: Attachment regenerator class * * @package RegenerateThumbnails * @since 3.0.0 */ /** * Regenerates the thumbnails for a given attachment. * * @since 3.0.0 */ class RegenerateThumbnails_Regenerator { /** * The WP_Post object for the attachment that is being operated on. * * @since 3.0.0 * * @var WP_Post */ public $attachment; /** * The full path to the original image so that it can be passed between methods. * * @since 3.0.0 * * @var string */ public $fullsizepath; /** * An array of thumbnail size(s) that were skipped during regeneration due to already existing. * A class variable is used so that the data can later be used to merge the size(s) back in. * * @since 3.0.0 * * @var array */ public $skipped_thumbnails = array(); /** * The metadata for the attachment before the regeneration process starts. * * @since 3.1.6 * * @var array */ private $old_metadata = array(); /** * Generates an instance of this class after doing some setup. * * MIME type is purposefully not validated in order to be more future proof and * to avoid duplicating a ton of logic that already exists in WordPress core. * * @since 3.0.0 * * @param int $attachment_id Attachment ID to process. * * @return RegenerateThumbnails_Regenerator|WP_Error A new instance of RegenerateThumbnails_Regenerator on success, or WP_Error on error. */ public static function get_instance( $attachment_id ) { $attachment = get_post( $attachment_id ); if ( ! $attachment ) { return new WP_Error( 'regenerate_thumbnails_regenerator_attachment_doesnt_exist', __( 'No attachment exists with that ID.', 'regenerate-thumbnails' ), array( 'status' => 404, ) ); } // We can only regenerate thumbnails for attachments. if ( 'attachment' !== get_post_type( $attachment ) ) { return new WP_Error( 'regenerate_thumbnails_regenerator_not_attachment', __( 'This item is not an attachment.', 'regenerate-thumbnails' ), array( 'status' => 400, ) ); } // Don't touch any attachments that are being used as a site icon. Their thumbnails are usually custom cropped. if ( self::is_site_icon( $attachment ) ) { return new WP_Error( 'regenerate_thumbnails_regenerator_is_site_icon', __( "This attachment is a site icon and therefore the thumbnails shouldn't be touched.", 'regenerate-thumbnails' ), array( 'status' => 415, 'attachment' => $attachment, ) ); } return new RegenerateThumbnails_Regenerator( $attachment ); } /** * The constructor for this class. Don't call this directly, see get_instance() instead. * This is done so that WP_Error objects can be returned during class initiation. * * @since 3.0.0 * * @param WP_Post $attachment The WP_Post object for the attachment that is being operated on. */ private function __construct( WP_Post $attachment ) { $this->attachment = $attachment; } /** * Returns whether the attachment is or was a site icon. * * @since 3.0.0 * * @param WP_Post $attachment The WP_Post object for the attachment that is being operated on. * * @return bool Whether the attachment is or was a site icon. */ public static function is_site_icon( WP_Post $attachment ) { return ( 'site-icon' === get_post_meta( $attachment->ID, '_wp_attachment_context', true ) ); } /** * Get the path to the fullsize attachment. * * @return string|WP_Error The path to the fullsize attachment, or a WP_Error object on error. */ public function get_fullsizepath() { if ( $this->fullsizepath ) { return $this->fullsizepath; } if ( function_exists( 'wp_get_original_image_path' ) ) { $this->fullsizepath = wp_get_original_image_path( $this->attachment->ID ); } else { $this->fullsizepath = get_attached_file( $this->attachment->ID ); } if ( false === $this->fullsizepath || ! file_exists( $this->fullsizepath ) ) { $error = new WP_Error( 'regenerate_thumbnails_regenerator_file_not_found', sprintf( /* translators: The relative upload path to the attachment. */ __( "The fullsize image file cannot be found in your uploads directory at %s. Without it, new thumbnail images can't be generated.", 'regenerate-thumbnails' ), _wp_relative_upload_path( $this->fullsizepath ) ), array( 'status' => 404, 'fullsizepath' => _wp_relative_upload_path( $this->fullsizepath ), 'attachment' => $this->attachment, ) ); $this->fullsizepath = $error; } return $this->fullsizepath; } /** * Regenerate the thumbnails for this instance's attachment. * * @since 3.0.0 * * @param array|string $args { * Optional. Array or string of arguments for thumbnail regeneration. * * @type bool $only_regenerate_missing_thumbnails Skip regenerating existing thumbnail files. Default true. * @type bool $delete_unregistered_thumbnail_files Delete any thumbnail sizes that are no longer registered. Default false. * } * * @return mixed|WP_Error Metadata for attachment (see wp_generate_attachment_metadata()), or WP_Error on error. */ public function regenerate( $args = array() ) { global $wpdb; $args = wp_parse_args( $args, array( 'only_regenerate_missing_thumbnails' => true, 'delete_unregistered_thumbnail_files' => false, ) ); $fullsizepath = $this->get_fullsizepath(); if ( is_wp_error( $fullsizepath ) ) { $fullsizepath->add_data( array( 'attachment' => $this->attachment ) ); return $fullsizepath; } $this->old_metadata = wp_get_attachment_metadata( $this->attachment->ID ); if ( $args['only_regenerate_missing_thumbnails'] ) { add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_to_only_missing_thumbnails' ), 10, 2 ); } require_once( ABSPATH . 'wp-admin/includes/admin.php' ); $new_metadata = wp_generate_attachment_metadata( $this->attachment->ID, $fullsizepath ); if ( $args['only_regenerate_missing_thumbnails'] ) { // Thumbnail sizes that existed were removed and need to be added back to the metadata. foreach ( $this->skipped_thumbnails as $skipped_thumbnail ) { if ( ! empty( $this->old_metadata['sizes'][ $skipped_thumbnail ] ) ) { $new_metadata['sizes'][ $skipped_thumbnail ] = $this->old_metadata['sizes'][ $skipped_thumbnail ]; } } $this->skipped_thumbnails = array(); remove_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_to_only_missing_thumbnails' ), 10 ); } $wp_upload_dir = dirname( $fullsizepath ) . DIRECTORY_SEPARATOR; if ( $args['delete_unregistered_thumbnail_files'] ) { // Delete old sizes that are still in the metadata. $intermediate_image_sizes = get_intermediate_image_sizes(); foreach ( $this->old_metadata['sizes'] as $old_size => $old_size_data ) { if ( in_array( $old_size, $intermediate_image_sizes ) ) { continue; } wp_delete_file( $wp_upload_dir . $old_size_data['file'] ); unset( $new_metadata['sizes'][ $old_size ] ); } $relative_path = dirname( $new_metadata['file'] ) . DIRECTORY_SEPARATOR; // It's possible to upload an image with a filename like image-123x456.jpg and it shouldn't be deleted. $whitelist = $wpdb->get_col( $wpdb->prepare( " SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND meta_value REGEXP %s /* Regenerate Thumbnails */ ", '^' . preg_quote( $relative_path ) . '[^' . preg_quote( DIRECTORY_SEPARATOR ) . ']+-[0-9]+x[0-9]+\.' ) ); $whitelist = array_map( 'basename', $whitelist ); $filelist = array(); foreach ( scandir( $wp_upload_dir ) as $file ) { if ( '.' == $file || '..' == $file || ! is_file( $wp_upload_dir . $file ) ) { continue; } $filelist[] = $file; } $registered_thumbnails = array(); foreach ( $new_metadata['sizes'] as $size ) { $registered_thumbnails[] = $size['file']; } $fullsize_parts = pathinfo( $fullsizepath ); foreach ( $filelist as $file ) { if ( in_array( $file, $whitelist ) || in_array( $file, $registered_thumbnails ) ) { continue; } if ( ! preg_match( '#^' . preg_quote( $fullsize_parts['filename'], '#' ) . '-[0-9]+x[0-9]+\.' . preg_quote( $fullsize_parts['extension'], '#' ) . '$#', $file ) ) { continue; } wp_delete_file( $wp_upload_dir . $file ); } } elseif ( ! empty( $this->old_metadata ) && ! empty( $this->old_metadata['sizes'] ) && is_array( $this->old_metadata['sizes'] ) ) { // If not deleting, rename any size conflicts to avoid them being lost if the file still exists. foreach ( $this->old_metadata['sizes'] as $old_size => $old_size_data ) { if ( empty( $new_metadata['sizes'][ $old_size ] ) ) { $new_metadata['sizes'][ $old_size ] = $this->old_metadata['sizes'][ $old_size ]; continue; } $new_size_data = $new_metadata['sizes'][ $old_size ]; if ( $new_size_data['width'] !== $old_size_data['width'] && $new_size_data['height'] !== $old_size_data['height'] && file_exists( $wp_upload_dir . $old_size_data['file'] ) ) { $new_metadata['sizes'][ $old_size . '_old_' . $old_size_data['width'] . 'x' . $old_size_data['height'] ] = $old_size_data; } } } wp_update_attachment_metadata( $this->attachment->ID, $new_metadata ); return $new_metadata; } /** * Filters the list of thumbnail sizes to only include those which have missing files. * * @since 3.0.0 * * @param array $sizes An associative array of registered thumbnail image sizes. * @param array $fullsize_metadata An associative array of fullsize image metadata: width, height, file. * * @return array An associative array of image sizes. */ public function filter_image_sizes_to_only_missing_thumbnails( $sizes, $fullsize_metadata ) { if ( ! $sizes ) { return $sizes; } $fullsizepath = $this->get_fullsizepath(); if ( is_wp_error( $fullsizepath ) ) { return $sizes; } $editor = wp_get_image_editor( $fullsizepath ); if ( is_wp_error( $editor ) ) { return $sizes; } $metadata = $this->old_metadata; // This is based on WP_Image_Editor_GD::multi_resize() and others. foreach ( $sizes as $size => $size_data ) { if ( empty( $metadata['sizes'][ $size ] ) ) { continue; } if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { continue; } if ( ! isset( $size_data['width'] ) ) { $size_data['width'] = null; } if ( ! isset( $size_data['height'] ) ) { $size_data['height'] = null; } if ( ! isset( $size_data['crop'] ) ) { $size_data['crop'] = false; } $thumbnail = $this->get_thumbnail( $editor, $fullsize_metadata['width'], $fullsize_metadata['height'], $size_data['width'], $size_data['height'], $size_data['crop'] ); // The false check filters out thumbnails that would be larger than the fullsize image. // The size comparison makes sure that the size is also correct. if ( false === $thumbnail || ( $thumbnail['width'] === $metadata['sizes'][ $size ]['width'] && $thumbnail['height'] === $metadata['sizes'][ $size ]['height'] && file_exists( $thumbnail['filename'] ) ) ) { $this->skipped_thumbnails[] = $size; unset( $sizes[ $size ] ); } } /** * Filters the list of missing thumbnail sizes if you want to add/remove any. * * @since 3.1.0 * * @param array $sizes An associative array of image sizes that are missing. * @param array $fullsize_metadata An associative array of fullsize image metadata: width, height, file. * @param object $this The current instance of this class. * * @return array An associative array of image sizes. */ return apply_filters( 'regenerate_thumbnails_missing_thumbnails', $sizes, $fullsize_metadata, $this ); } /** * Generate the thumbnail filename and dimensions for a given set of constraint dimensions. * * @since 3.0.0 * * @param WP_Image_Editor|WP_Error $editor An instance of WP_Image_Editor, as returned by wp_get_image_editor(). * @param int $fullsize_width The width of the fullsize image. * @param int $fullsize_height The height of the fullsize image. * @param int $thumbnail_width The width of the thumbnail. * @param int $thumbnail_height The height of the thumbnail. * @param bool $crop Whether to crop or not. * * @return array|false An array of the filename, thumbnail width, and thumbnail height, * or false on failure to resize such as the thumbnail being larger than the fullsize image. */ public function get_thumbnail( $editor, $fullsize_width, $fullsize_height, $thumbnail_width, $thumbnail_height, $crop ) { $dims = image_resize_dimensions( $fullsize_width, $fullsize_height, $thumbnail_width, $thumbnail_height, $crop ); if ( ! $dims ) { return false; } list( , , , , $dst_w, $dst_h ) = $dims; $suffix = "{$dst_w}x{$dst_h}"; $file_ext = strtolower( pathinfo( $this->get_fullsizepath(), PATHINFO_EXTENSION ) ); return array( 'filename' => $editor->generate_filename( $suffix, null, $file_ext ), 'width' => $dst_w, 'height' => $dst_h, ); } /** * Update the post content of any public post types (posts and pages by default) * that make use of this attachment. * * @since 3.0.0 * * @param array|string $args { * Optional. Array or string of arguments for controlling the updating. * * @type array $post_type The post types to update. Defaults to public post types (posts and pages by default). * @type array $post_ids Specific post IDs to update as opposed to any that uses the attachment. * @type int $posts_per_loop How many posts to query at a time to keep memory usage down. You shouldn't need to modify this. * } * * @return array|WP_Error List of post IDs that were modified. The key is the post ID and the value is either the post ID again or a WP_Error object if wp_update_post() failed. */ public function update_usages_in_posts( $args = array() ) { // Temporarily disabled until it can be even better tested for edge cases return array(); $args = wp_parse_args( $args, array( 'post_type' => array(), 'post_ids' => array(), 'posts_per_loop' => 10, ) ); if ( empty( $args['post_type'] ) ) { $args['post_type'] = array_values( get_post_types( array( 'public' => true ) ) ); unset( $args['post_type']['attachment'] ); } $offset = 0; $posts_updated = array(); while ( true ) { $posts = get_posts( array( 'numberposts' => $args['posts_per_loop'], 'offset' => $offset, 'orderby' => 'ID', 'order' => 'ASC', 'include' => $args['post_ids'], 'post_type' => $args['post_type'], 's' => 'wp-image-' . $this->attachment->ID, // For faster queries. 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); if ( ! $posts ) { break; } $offset += $args['posts_per_loop']; foreach ( $posts as $post ) { $content = $post->post_content; $search = array(); $replace = array(); // Find all tags for this attachment and update them. preg_match_all( '#]+wp-image-' . $this->attachment->ID . '[^>]+/>#i', $content, $matches, PREG_SET_ORDER ); if ( $matches ) { foreach ( $matches as $img_tag ) { preg_match( '# class="([^"]+)?size-([^" ]+)#i', $img_tag[0], $thumbnail_size ); if ( $thumbnail_size ) { $thumbnail = image_downsize( $this->attachment->ID, $thumbnail_size[2] ); if ( ! $thumbnail ) { continue; } $search[] = $img_tag[0]; $img_tag[0] = preg_replace( '# src="[^"]+"#i', ' src="' . esc_url( $thumbnail[0] ) . '"', $img_tag[0] ); $img_tag[0] = preg_replace( '# width="[^"]+" height="[^"]+"#i', ' width="' . esc_attr( $thumbnail[1] ) . '" height="' . esc_attr( $thumbnail[2] ) . '"', $img_tag[0] ); $replace[] = $img_tag[0]; } } } $content = str_replace( $search, $replace, $content ); $search = array(); $replace = array(); // Update the width in any [caption] shortcodes. preg_match_all( '#\[caption id="attachment_' . $this->attachment->ID . '"([^\]]+)? width="[^"]+"\]([^\[]+)size-([^" ]+)([^\[]+)\[\/caption\]#i', $content, $matches, PREG_SET_ORDER ); if ( $matches ) { foreach ( $matches as $match ) { $thumbnail = image_downsize( $this->attachment->ID, $match[3] ); if ( ! $thumbnail ) { continue; } $search[] = $match[0]; $replace[] = '[caption id="attachment_' . $this->attachment->ID . '"' . $match[1] . ' width="' . esc_attr( $thumbnail[1] ) . '"]' . $match[2] . 'size-' . $match[3] . $match[4] . '[/caption]'; } } $content = str_replace( $search, $replace, $content ); $updated_post_object = (object) array( 'ID' => $post->ID, 'post_content' => $content, ); $posts_updated[ $post->ID ] = wp_update_post( $updated_post_object, true ); } } return $posts_updated; } /** * Returns information about the current attachment for use in the REST API. * * @since 3.0.0 * * @return array|WP_Error The attachment name, fullsize URL, registered thumbnail size status, and any unregistered sizes, or WP_Error on error. */ public function get_attachment_info() { $fullsizepath = $this->get_fullsizepath(); if ( is_wp_error( $fullsizepath ) ) { $fullsizepath->add_data( array( 'attachment' => $this->attachment ) ); return $fullsizepath; } $editor = wp_get_image_editor( $fullsizepath ); if ( is_wp_error( $editor ) ) { // Display a more helpful error message. if ( 'image_no_editor' === $editor->get_error_code() ) { $editor = new WP_Error( 'image_no_editor', __( 'The current image editor cannot process this file type.', 'regenerate-thumbnails' ) ); } $editor->add_data( array( 'attachment' => $this->attachment, 'status' => 415, ) ); return $editor; } $metadata = wp_get_attachment_metadata( $this->attachment->ID ); if ( false === $metadata || ! is_array( $metadata ) ) { return new WP_Error( 'regenerate_thumbnails_regenerator_no_metadata', __( 'Unable to load the metadata for this attachment.', 'regenerate-thumbnails' ), array( 'status' => 404, 'attachment' => $this->attachment, ) ); } if ( ! isset( $metadata['sizes'] ) ) { $metadata['sizes'] = array(); } // PDFs don't have width/height set. $width = ( isset( $metadata['width'] ) ) ? $metadata['width'] : null; $height = ( isset( $metadata['height'] ) ) ? $metadata['height'] : null; require_once( ABSPATH . '/wp-admin/includes/image.php' ); $preview = false; if ( file_is_displayable_image( $fullsizepath ) ) { $preview = wp_get_attachment_url( $this->attachment->ID ); } elseif ( is_array( $metadata['sizes'] ) && is_array( $metadata['sizes']['full'] ) && ! empty( $metadata['sizes']['full']['file'] ) ) { $preview = str_replace( wp_basename( $fullsizepath ), $metadata['sizes']['full']['file'], wp_get_attachment_url( $this->attachment->ID ) ); if ( ! file_exists( $preview ) ) { $preview = false; } } $response = array( 'name' => ( $this->attachment->post_title ) ? $this->attachment->post_title : sprintf( __( 'Attachment %d', 'regenerate-thumbnails' ), $this->attachment->ID ), 'preview' => $preview, 'relative_path' => _wp_get_attachment_relative_path( $fullsizepath ) . DIRECTORY_SEPARATOR . wp_basename( $fullsizepath ), 'edit_url' => get_edit_post_link( $this->attachment->ID, 'raw' ), 'width' => $width, 'height' => $height, 'registered_sizes' => array(), 'unregistered_sizes' => array(), ); $wp_upload_dir = dirname( $fullsizepath ) . DIRECTORY_SEPARATOR; $registered_sizes = RegenerateThumbnails()->get_thumbnail_sizes(); if ( 'application/pdf' === get_post_mime_type( $this->attachment ) ) { $registered_sizes = array_intersect_key( $registered_sizes, array( 'thumbnail' => true, 'medium' => true, 'large' => true, ) ); } // Check the status of all currently registered sizes. foreach ( $registered_sizes as $size ) { // Width and height are needed to generate the thumbnail filename. if ( $width && $height ) { $thumbnail = $this->get_thumbnail( $editor, $width, $height, $size['width'], $size['height'], $size['crop'] ); if ( $thumbnail ) { $size['filename'] = wp_basename( $thumbnail['filename'] ); $size['fileexists'] = file_exists( $thumbnail['filename'] ); } else { $size['filename'] = false; $size['fileexists'] = false; } } elseif ( ! empty( $metadata['sizes'][ $size['label'] ]['file'] ) ) { $size['filename'] = wp_basename( $metadata['sizes'][ $size['label'] ]['file'] ); $size['fileexists'] = file_exists( $wp_upload_dir . $metadata['sizes'][ $size['label'] ]['file'] ); } else { $size['filename'] = false; $size['fileexists'] = false; } $response['registered_sizes'][] = $size; } if ( ! $width && ! $height && is_array( $metadata['sizes']['full'] ) ) { $response['registered_sizes'][] = array( 'label' => 'full', 'width' => $metadata['sizes']['full']['width'], 'height' => $metadata['sizes']['full']['height'], 'filename' => $metadata['sizes']['full']['file'], 'fileexists' => file_exists( $wp_upload_dir . $metadata['sizes']['full']['file'] ), ); } // Look at the attachment metadata and see if we have any extra files from sizes that are no longer registered. foreach ( $metadata['sizes'] as $label => $size ) { if ( ! file_exists( $wp_upload_dir . $size['file'] ) ) { continue; } // An unregistered size could match a registered size's dimensions. Ignore these. foreach ( $response['registered_sizes'] as $registered_size ) { if ( $size['file'] === $registered_size['filename'] ) { continue 2; } } if ( ! empty( $registered_sizes[ $label ] ) ) { /* translators: Used for listing old sizes of currently registered thumbnails */ $label = sprintf( __( '%s (old)', 'regenerate-thumbnails' ), $label ); } $response['unregistered_sizes'][] = array( 'label' => $label, 'width' => $size['width'], 'height' => $size['height'], 'filename' => $size['file'], 'fileexists' => true, ); } return $response; } } /** * Lib of functions related grid shortcodes elements. */ if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * Get taxonomies types for autocomplete. * * @param mixed $term * * @return array|bool * @since 4.5.2 */ function vc_autocomplete_taxonomies_field_render( $term ) { $vc_taxonomies_types = vc_taxonomies_types(); // phpcs:ignore $terms = get_terms( array_keys( $vc_taxonomies_types ), array( 'include' => array( $term['value'] ), 'hide_empty' => false, ) ); $data = false; if ( is_array( $terms ) && 1 === count( $terms ) ) { $term = $terms[0]; $data = vc_get_term_object( $term ); } return $data; } /** * Get taxonomies search fields for autocomplete. * * @param string $search_string * * @return array|bool * @since 4.5.2 */ function vc_autocomplete_taxonomies_field_search( $search_string ) { $data = array(); $vc_filter_by = vc_post_param( 'vc_filter_by', '' ); $vc_filter_by_post_type = vc_post_param( 'vc_filter_post_type', '' ); $vc_taxonomies_types = strlen( $vc_filter_by ) > 0 ? array( $vc_filter_by ) : array_keys( vc_taxonomies_types( $vc_filter_by_post_type ) ); if ( empty( $vc_taxonomies_types ) ) { return array(); } // phpcs:ignore $vc_taxonomies = get_terms( $vc_taxonomies_types, array( 'hide_empty' => false, 'search' => $search_string, ) ); if ( is_array( $vc_taxonomies ) && ! empty( $vc_taxonomies ) ) { foreach ( $vc_taxonomies as $t ) { if ( is_object( $t ) ) { $data[] = vc_get_term_object( $t ); } } } return $data; } /** * Add search by title to search query. * * @param string $search * @param WP_Query $wp_query * * @return string */ function vc_search_by_title_only( $search, $wp_query ) { global $wpdb; if ( empty( $search ) ) { return $search; } // skip processing - no search term in query. $q = $wp_query->query_vars; if ( isset( $q['vc_search_by_title_only'] ) && $q['vc_search_by_title_only'] ) { $n = ! empty( $q['exact'] ) ? '' : '%'; $search = ''; $searchand = ''; foreach ( (array) $q['search_terms'] as $term ) { $term = $wpdb->esc_like( $term ); $like = $n . $term . $n; $search .= $searchand . $wpdb->prepare( "($wpdb->posts.post_title LIKE %s)", $like ); $searchand = ' AND '; } if ( ! empty( $search ) ) { $search = " AND ({$search}) "; if ( ! is_user_logged_in() ) { $search .= " AND ($wpdb->posts.post_password = '') "; } } } return $search; } /** * Include search field to search query. * * @param string $search_string * * @return array */ function vc_include_field_search( $search_string ) { $query = $search_string; $data = array(); $args = array( 's' => $query, 'post_type' => 'any', ); $args['vc_search_by_title_only'] = true; $args['numberposts'] = - 1; if ( 0 === strlen( $args['s'] ) ) { unset( $args['s'] ); } add_filter( 'posts_search', 'vc_search_by_title_only', 500, 2 ); $posts = get_posts( $args ); if ( is_array( $posts ) && ! empty( $posts ) ) { foreach ( $posts as $post ) { $data[] = array( 'value' => $post->ID, 'label' => $post->post_title, 'group' => $post->post_type, ); } } return $data; } /** * Include render field. * * @param array $value * * @return array|bool */ function vc_include_field_render( $value ) { $post = get_post( $value['value'] ); return is_null( $post ) ? false : array( 'label' => $post->post_title, 'value' => $post->ID, 'group' => $post->post_type, ); } /** * Exclude search field from search query. * * @param array $data_arr * * @return array */ function vc_exclude_field_search( $data_arr ) { $query = isset( $data_arr['query'] ) ? $data_arr['query'] : null; $term = isset( $data_arr['term'] ) ? $data_arr['term'] : ''; $data = array(); $args = ! empty( $query ) ? array( 's' => $term, 'post_type' => $query, ) : array( 's' => $term, 'post_type' => 'any', ); $args['vc_search_by_title_only'] = true; $args['numberposts'] = - 1; if ( 0 === strlen( $args['s'] ) ) { unset( $args['s'] ); } add_filter( 'posts_search', 'vc_search_by_title_only', 500, 2 ); $posts = get_posts( $args ); if ( is_array( $posts ) && ! empty( $posts ) ) { foreach ( $posts as $post ) { $data[] = array( 'value' => $post->ID, 'label' => $post->post_title, 'group' => $post->post_type, ); } } return $data; } /** * Exclude render field. * * @param array $value * * @return array|bool */ function vc_exclude_field_render( $value ) { $post = get_post( $value['value'] ); return is_null( $post ) ? false : array( 'label' => $post->post_title, 'value' => $post->ID, 'group' => $post->post_type, ); } Smog Stations | ABC STAR Stations - $20 Smog Coupon

5 Smog Check Stations

ABC STAR STATIONS

Get To Know Us

$20 SMOG COUPON

Our STAR stations offer smog checks and smog tests for all vehicles. All DMV smog check, smog inspections, smog certifications, smog testing, smog test only, STAR smog check, smog certifications, and smog check coupons.
ABC-STAR-STATIONS-Coupons

ABC Smog Check STAR Station

4555 E gage Ave, Bell, CA 90201

ABC Smog Test Only

14162 Lambert Rd Whittier, CA 90605

ABC Smog Check

3875 E 3rd St Los Angeles, CA 90063

ABC Eastern Smog Test Only

4479 E Olympic Bivd Los Angeles CA 90023

ABC Olympic Smog Test Only

5929 E Olympic Bivd Los Angeles CA 90022

Call Us Anytime!

Our Services

ABC STAR STATIONS

We have 5 convenient Smog locations in LA, Bell, Whittier, East LA, smog check 90063 to choose from.

ABC EASTERN STAR TEST ONLY CENTER

4479 E. OLYMPIC BLVD LOS ANGELES, CA 90023
Call: 323-262-2292

BELL STAR TEST ONLY CENTER

4555 E. Gage Ave Bell CA 90201
Call: 323-562-4195

EAST LOS ANGELES STAR TEST ONLY

385 E. 3RD ST LOS ANGELES, CA 90063
Call: 323-261-1812

ABC STAR WHITTIER TEST ONLY

14162 E. LAMBERT RD WHITTIER CA 90603
Call: 562-696-1225

ABC OLYMPIC STAR TEST ONLY CENTER

5929 E. OLYMPIC BLVD LOS ANGELES, CA 90022
Call: 323-887-9819

Why Us ?

Because we are the best Smog Check Station

Save $$ now with our special online smog coupons!

We have 5 convenient Smog locations in LA, Bell, Whittier, East LA, smog check 90063 to choose from.

We SMOG all vehicles

We Smog All types of DMV Smog Check, All Types of Vehicles, Hybrid, Diesel Smog Check, Get Your Smog Certificate with Discount Smog Coupon Today

Diesel Smog Check

Get a Discount Smog Coupon Near Me Los Angeles, WHITTIER, Bell We CERTIFY All Vehicles | All Types of DMV Smog Inspection in San Diego

Test Only Smog

ABC Smog Stations in California are your top choice for all smog check needs, offering a comprehensive range of services designed to meet California's strict emissions standards.

0 %

ABC Smog Stations

Our STAR stations

We Are STAR Station

ABC Smog Stations offers all types of DMV Smog Checks, SUV Smogs, Diesel Smog Checks, Out-of-State Smog Checks, and Smog Test Only services with a Discount Smog Coupon.

Smog Coupon

$20 OFF

($10 off for all STAR certification)
Offer Good On All Cars & Trucks
Must Present Coupon in Print or Mobile

Brake & Lamp Coupons

$20 OFF

These inspections check critical components like brake condition, brake fluid, and vehicle lighting systems.

Our Services

ABC Stations

We can Smog Check all cars, SUVs, and trucks, QUICK smog inspections

Have A Questions? Call Us Now!

Customer Services

Contact us

How it works

5 STAR Stations

We have 5 convenient Smog locations in LA, Bell, Whittier, East LA, and 90063 to choose from.

DMV Smog Checks

A DMV Smog Check in California is a mandatory emissions test required every two years for most gasoline-powered vehicles 1976 and newer

California Smog Check

A Diesel Smog Check is a required emissions test for diesel vehicles in California that measures visible smoke and pollutant levels to ensure the vehicle

Gross Polluter Certification

Gross Polluter Certification refers to the designation for vehicles that emit more than twice the legal limit of pollutants, requiring them to undergo specific repairs

Smog Check Certification

A Smog Check Certification is issued after a vehicle passes an emissions test, which is often required biennially for vehicle registration renewal,

Gallery

Our Stations

We have 5 convenient Smog locations in LA, Bell, Whittier, East LA, and 90063 to choose from. We Smog All types of DMV Smog Check, All Types of Vehicles, Hybrid, Diesel Smog Check, Get Your Smog Certificate with Discount Smog Coupon Today

Get Special Offers!

Save $$ now with our special online smog coupons!

We have 5 convenient Smog locations in LA, Bell, Whittier, East LA, smog check 90063 to choose from.