@param string $old_slug
@param string|array $names
@param int $post_id

@return array|false An array containing `term_id` and `term_taxonomy_id`, false otherwise.
769835
public function convert( $old_slug, $names, $post_id ) {

		$new_slug = $this->maybeUpgradeSlug( $old_slug );
		if ( $new_slug === $old_slug ) {
			return false; // Nothing to convert
		}

		if ( ! is_array( $names ) ) {
			$names = [ $names ];
		}

		$result = false;
		foreach ( $names as $contributors ) {
			$values = oxford_comma_explode( $contributors );
			foreach ( $values as $v ) {
				$result = $this->insert( $v, $post_id, $new_slug );
			}
		}

		return $result;
	}
514665
public function insert( $full_name, $post_id = 0, $contributor_type = 'pb_authors' ) {
		$full_name = trim( $full_name );
		$slug = sanitize_title_with_dashes( remove_accents( $full_name ), '', 'save' );
		$term = get_term_by( 'slug', $slug, self::TAXONOMY );
		if ( $term ) {
			$results = [
				'term_id' => $term->term_id,
				'term_taxonomy_id' => $term->term_taxonomy_id,
			];
		} else {
			$results = wp_insert_term(
				$full_name, self::TAXONOMY, [
					'slug' => $slug,
				]
			);
		}

		if ( $post_id && is_array( $results ) ) {
			$this->link( $results['term_id'], $post_id, $contributor_type );
		}

		return is_array( $results ) ? $results : false;
	}
907521
public function get_custom_taxonomy($custom_taxonomy_id){
    global $wpdb;

    $query = sprintf('SELECT * FROM %s WHERE id = %s',MF_TABLE_CUSTOM_TAXONOMY,$custom_taxonomy_id);
    $custom_taxonomy = $wpdb->get_row( $query, ARRAY_A );
    if($custom_taxonomy){
      $custom_taxonomy = unserialize($custom_taxonomy['arguments']);
      $custom_taxonomy['core']['id'] = $custom_taxonomy_id;
      return $custom_taxonomy;
    }
    return false;
  }
425574
public function save_post_detect_new( $new_status, $old_status, $post ) {

		if ( $post ) {
			self::$old_post_status[ $post->post_type ] = $old_status;
		}

	}
384879
public function termGet(int $term_id)
    {
        $value = get_term_meta($term_id, $this->getName(), true);

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
1110848
public function scopeHasCategories($query, $taxonomy_ids)
    {
        return $query->whereHas('taxed', function($q) use($taxonomy_ids) {
            $q->whereIn('taxonomy_id', $taxonomy_ids);
        });
    }
1362288
public function handle($old, $new)
    {
        if ( ! $this->canHandle($old) || ! $this->canHandle($new)) {
            return null;
        }

        if (((string) $new->getReturnType())) {
            return false;
        }

        if (((string) $new->getReturnType()) == ((string) $old->getReturnType())) {
            return false;
        }

        $this->lastException = new FailedConstraint(
            sprintf(
                '%s::%s() return type "%s" were removed',
                $old->getAttribute('parent')->namespacedName,
                $old->name,
                $old->getReturnType(),
                $new->getReturnType()
            )
        );

        return true;
    }
1222628
public static function get_template_part( $slug, $name = null, array $vars = [] ) {
		WP_View_Controller\Helper\get_template_part( $slug, $name, $vars );
	}
82709
private function create_taxonomy_replace_tag( $post_id, $permalink ) {
		$search  = array();
		$replace = array();

		$taxonomies = CPTP_Util::get_taxonomies( true );

		// %taxnomomy% -> parent/child
		foreach ( $taxonomies as $taxonomy => $objects ) {

			if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
				$terms = get_the_terms( $post_id, $taxonomy );

				if ( $terms && ! is_wp_error( $terms ) ) {
					$parents  = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
					$newTerms = array();
					foreach ( $terms as $key => $term ) {
						if ( ! in_array( $term->term_id, $parents , true ) ) {
							$newTerms[] = $term;
						}
					}

					$term_obj  = reset( $newTerms );
					$term_slug = $term_obj->slug;

					if ( isset( $term_obj->parent ) && $term_obj->parent ) {
						$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
					}
				}

				if ( isset( $term_slug ) ) {
					$search[]  = '%' . $taxonomy . '%';
					$replace[] = $term_slug;
				}
			}
		}

		return array(
			'search' => $search,
			'replace' => $replace,
		);
	}
1042424
protected function getForeignKeysMigrations($new = [], $old = [])
    {
        if (empty($new['tables'])) {
            return [];
        }
        $output = [];
        foreach ($new['tables'] as $tableId => $newTable) {
            if ($newTable['table']['table_name'] === $this->options['default_migration_table']) {
                continue;
            }
            $oldTable = $old['tables'][$tableId];

            if (!empty($oldTable['foreign_keys'])) {
                foreach ($oldTable['foreign_keys'] as $fkName => $fkData) {
                    if (!isset($newTable['foreign_keys'][$fkName])) {
                        $output[] = $this->getForeignKeyRemove($tableId, $fkName);
                    }
                }
            }
            if (!empty($newTable['foreign_keys'])) {
                foreach ($newTable['foreign_keys'] as $fkName => $fkData) {
                    if (!isset($oldTable['foreign_keys'][$fkName])) {
                        $output[] = $this->getForeignKeyCreate($tableId, $fkName);
                    }
                }
            }
        }

        return $output;
    }
1013882
public function column_content( $column_name, $post_id ) {
		// Bail out.
		if ( empty( $this->columns )
			|| ! in_array( $column_name, array_keys( $this->columns ), true )
		) {
			return;
		}

		$column = $this->columns[ $column_name ];

		if ( 'thumbnail' === $column_name ) {
			$src = get_the_post_thumbnail_url( $post_id, 'thumbnail' );

			if ( empty( $src ) ) {
				return;
			}

			$styles = '';

			foreach ( [ 'width', 'height' ] as $attr ) {
				if ( isset( $column[ $attr ] ) ) {
					$styles .= $attr . ':' . $column[ $attr ] . 'px;';
				}
			}

			if ( ! empty( $styles ) ) {
				$styles = ' style="' . $styles . '"';
			}

			echo '<img src="' . esc_attr( $src ) . '"' . $styles . '>';

			return;
		}

		if ( 'acf' === $column['type'] ) {
			$value = get_field( $column_name, $post_id );
		} else {
			$value = get_post_meta( $post_id, $column_name, true );
		}

		if ( is_callable( $column['transform'] ) ) {
			$value = call_user_func( $column['transform'], $value, $post_id );
		}

		echo $value;
	}
262308
def namedb_get_num_names( cur, current_block, include_expired=False ):
    
    unexpired_query = ""
    unexpired_args = ()

    if not include_expired:
        # count all names, including expired ones
        unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
        unexpired_query = 'WHERE {}'.format(unexpired_query)

    query = "SELECT COUNT(name_records.name) FROM name_records JOIN namespaces ON name_records.namespace_id = namespaces.namespace_id " + unexpired_query + ";"
    args = unexpired_args

    num_rows = namedb_select_count_rows( cur, query, args, count_column='COUNT(name_records.name)' )
    return num_rows
801851
public function onPostHandleRequestWithCollection(Collection $oldCollection, Collection $newCollection) {
        $deleted = 0;
        foreach ($oldCollection as $current) {
            if (true === $newCollection->contains($current)) {
                continue;
            }
            $this->getObjectManager()->remove($current);
            ++$deleted;
        }
        return $deleted;
    }
804957
public static function insertCategories($selectedCategories, $postID, $postTypeSlug)
    {
        if (count($selectedCategories)) {
            $categoriesIDs = [];
            $newCategoryRelation = [];
            foreach ($selectedCategories as $selectedCategory){
                $newCategoryRelation[] = [
                  'categoryID' => $selectedCategory['categoryID'],
                  'postID' => $postID,
                ];
                $categoriesIDs[] = $selectedCategory['categoryID'];
            }

            // if post is only in the archive
            // if post is in the main database
            $insertedCategories = (new CategoryRelation())->setTable($postTypeSlug.'_categories')->insert($newCategoryRelation);
            if ($insertedCategories) {
                return $categoriesIDs;
            }
        }
        return [];
    }
886322
public function load($term_id)
    {
        $info = get_term($term_id, $this->getTaxonomyKey());
        if (!is_object($info)) {
            return false;
        }

        $this->_info = (array) $info;

        // extra
        $option = get_option($this->getOptionID($term_id));
        if (!is_object($option) && !is_array($option)) {
            return true;
        }

        foreach ($option as $k => $v) {
            $this->set($k, $v);
        }

        return true;
    }
931275
public function handleBulkActions($redirect_to, $action_name, $post_ids) {
        if('ilab_rekognizer_process' === $action_name) {
            $posts_to_import = [];
            if (count($post_ids) > 0) {
                foreach($post_ids as $post_id) {
                    $meta = wp_get_attachment_metadata($post_id);
                    if (!empty($meta) && !isset($meta['s3'])) {
                        continue;
                    }

                    $mime = get_post_mime_type($post_id);
                    if (!in_array($mime, ['image/jpeg', 'image/jpg', 'image/png'])) {
                        continue;
                    }

                    $posts_to_import[] = $post_id;
                }
            }

            if(count($posts_to_import) > 0) {
                set_site_transient($this->batchPrefix().'_post_selection', $posts_to_import, 10);
                return 'admin.php?page='.$this->menuSlug();
            }
        }

        return $redirect_to;
    }
320368
public function unlink( $term_id, $post_id, $contributor_type = 'pb_authors' ) {
		if ( ! str_starts_with( $contributor_type, 'pb_' ) ) {
			$contributor_type = 'pb_' . $contributor_type;
		}
		if ( $this->isValid( $contributor_type ) ) {
			if ( preg_match( '/\d+/', $term_id ) ) {
				$term = get_term( $term_id, self::TAXONOMY ); // Get slug by Term ID
			} else {
				$term = get_term_by( 'slug', $term_id, self::TAXONOMY ); // Verify that slug is valid
			}
			if ( $term && ! is_wp_error( $term ) ) {
				wp_remove_object_terms( $post_id, $term->term_id, self::TAXONOMY );
				delete_post_meta( $post_id, $contributor_type, $term->slug );
				return true;
			}
		}
		return false;
	}