Disassociate a Contributor's Term ID to a Post ID (Taxonomy + Meta)

@param int|string $term_id
@param int $post_id
@param string $contributor_type

@return bool
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;
	}
33993
public function subscribeUser($user_id, $type)
    {
        if (!$this->userHasUnsubscribed($user_id, $type)) {
            return true;
        }

        // --------------------------------------------------------------------------

        $oDb = Factory::service('Database');
        $oDb->where('user_id', $user_id);
        $oDb->where('type', $type);
        $oDb->delete(NAILS_DB_PREFIX . 'user_email_blocker');

        return (bool) $oDb->affected_rows();
    }
1261444
public function delete_post( $id ) {

		$post = get_post( $id );

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

		$id        = $post->ID;
		$post_type = $post->post_type;

		return $this->delete_object( 'post_type', $id, $post_type );
	}
1360623
public function delete($_type = null, $id = null)
    {
        // setting up an event for the delete
        $_event = new Event('Controller.PostTypes.beforeDelete.' . $this->_type, $this, [
            'id' => $id,
        ]);
        $this->eventManager()->dispatch($_event);

        $postType = $this->Model->get($id);
        
        $this->request->allowMethod(['post', 'delete']);
        
        if ($this->Model->delete($postType)) {
            // setting up an event for the delete
            $_event = new Event('Controller.PostTypes.afterDelete.' . $this->_type, $this, [
                'id' => $id,
            ]);
            $this->eventManager()->dispatch($_event);
            
            $this->Flash->success(__('The {0} has been deleted.', [$this->Settings['type']]));
            
            return $this->redirect(['action' => 'index', 'type' => $this->_type]);
        } else {
            $this->Flash->error(__('The {0} could not be deleted. Please, try again.', [$this->Settings['type']]));
            return $this->redirect(['action' => 'index', 'type' => $this->_type]);
        }
    }
430979
protected function _delete($type, $id = null, array $parameters = []) {
        return $this->__delete($this->index(), $type, $id, $parameters);
    }
643072
protected function _deleteObject( $comment_id ) {
		$comment = get_comment( $comment_id );
		if ( ! $comment || is_wp_error( $comment ) ) {
			return false;
		}

		$deleted = wp_delete_comment( $comment_id, true );
		if ( $deleted ) {
			$this->_debug( 'Deleted comment with ID: ' . $comment_id );
			return true;
		}

		$this->_debug( 'Comment removal failed for ID: ' . $comment_id );
		return false;
	}
736123
public function get_custom_taxonomy_by_type($type_taxonomy){
    global $wpdb;

    $query = sprintf(
      "SELECT * FROM %s WHERE type = '%s'",
      MF_TABLE_CUSTOM_TAXONOMY,
      $type_taxonomy
    );

    $custom_taxonomy = $wpdb->get_row( $query, ARRAY_A );
    if($custom_taxonomy){
      $id = $custom_taxonomy['id'];
      $custom_taxonomy = unserialize($custom_taxonomy['arguments']);
      $custom_taxonomy['core']['id'] = $id;
      return $custom_taxonomy;
    }
    return false;
  }
1142028
protected function locateSection( $section_id, $post_type ) {
		if ( $post_type === 'glossary' ) {
			foreach ( $this->sourceBookGlossary as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $this->sourceBookGlossary[ $k ];
				}
			}
		} else {
			foreach ( $this->sourceBookStructure['_embedded'][ $post_type ] as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $this->sourceBookStructure['_embedded'][ $post_type ][ $k ];
				}
			};
		}
		return false;
	}
820521
public function removePostFromFavorite($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->delete(sprintf('/post/%d/favorite', $post_id));
    }
893987
function save_taxonomy( $term_id )
	{
		// verify nonce
		if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
		{
			return $term_id;
		}
		
		
		// for some weird reason, this is triggered by saving a menu... 
		if( !isset($_POST['taxonomy']) )
		{
			return;
		}
		
		// $post_id to save against
		$post_id = $_POST['taxonomy'] . '_' . $term_id;
						
		
		// update the post
		do_action('acf/save_post', $post_id);
		
	}
1205583
protected function _deleteObject( $blog_id ) {
		global $wpdb;

		$suppress = $wpdb->suppress_errors();
		wpmu_delete_blog( $blog_id, true );
		$wpdb->suppress_errors( $suppress );

		$this->_debug( 'Deleted blog with ID: ' . $blog_id );

		return true;
	}
570168
public function termSave($value, int $term_id)
    {
        $this->setValue($value);

        $previous = get_term_meta($term_id, $this->getName(), true);

        if (is_null($this->getValue()) || empty($this->getValue())) {
            delete_term_meta($term_id, $this->getName());
        } elseif (empty($previous)) {
            add_term_meta($term_id, $this->getName(), $this->getRawValue(), true);
        } else {
            update_term_meta($term_id, $this->getName(), $this->getRawValue(), $previous);
        }
    }
925101
public function _save_meta_description( $post_id ) {
		if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) {
			return;
		}

		if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) {
			return;
		}

		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
			return;
		}

		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return;
		}

		if ( ! isset( $_POST['wp-seo-meta-description'] ) ) {
			return;
		}

		if ( is_array( $_POST['wp-seo-meta-description'] ) ) {
			return;
		}

		$meta_description = wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-description' ) );
		update_post_meta( $post_id, 'wp-seo-meta-description', $meta_description );
	}
688432
public function delete_attachment( $_ID ) {

		global $wpdb;

		$_ID = (int) $_ID;

		do_action( 'pods_delete_attachment', $_ID );

		$file_types = "'" . implode( "', '", PodsForm::file_field_types() ) . "'";

		if ( ! pods_tableless() ) {
			$sql = "
                DELETE `rel`
                FROM `@wp_podsrel` AS `rel`
                LEFT JOIN `{$wpdb->posts}` AS `p`
                    ON
                        `p`.`post_type` = '_pods_field'
                        AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )
                LEFT JOIN `{$wpdb->postmeta}` AS `pm`
                    ON
                        `pm`.`post_id` = `p`.`ID`
                        AND `pm`.`meta_key` = 'type'
                        AND `pm`.`meta_value` IN ( {$file_types} )
                WHERE
                    `p`.`ID` IS NOT NULL
                    AND `pm`.`meta_id` IS NOT NULL
                    AND `rel`.`item_id` = {$_ID}";

			pods_query( $sql, false );
		}

		// Post Meta
		if ( ! empty( PodsMeta::$post_types ) ) {
			$sql = "
                DELETE `rel`
                FROM `@wp_postmeta` AS `rel`
                LEFT JOIN `{$wpdb->posts}` AS `p`
                    ON
                        `p`.`post_type` = '_pods_field'
                LEFT JOIN `{$wpdb->postmeta}` AS `pm`
                    ON
                        `pm`.`post_id` = `p`.`ID`
                        AND `pm`.`meta_key` = 'type'
                        AND `pm`.`meta_value` IN ( {$file_types} )
                WHERE
                    `p`.`ID` IS NOT NULL
                    AND `pm`.`meta_id` IS NOT NULL
                    AND `rel`.`meta_key` = `p`.`post_name`
                    AND `rel`.`meta_value` = '{$_ID}'";

			pods_query( $sql, false );
		}

		// User Meta
		if ( ! empty( PodsMeta::$user ) ) {
			$sql = "
                DELETE `rel`
                FROM `@wp_usermeta` AS `rel`
                LEFT JOIN `{$wpdb->posts}` AS `p`
                    ON
                        `p`.`post_type` = '_pods_field'
                LEFT JOIN `{$wpdb->postmeta}` AS `pm`
                    ON
                        `pm`.`post_id` = `p`.`ID`
                        AND `pm`.`meta_key` = 'type'
                        AND `pm`.`meta_value` IN ( {$file_types} )
                WHERE
                    `p`.`ID` IS NOT NULL
                    AND `pm`.`meta_id` IS NOT NULL
                    AND `rel`.`meta_key` = `p`.`post_name`
                    AND `rel`.`meta_value` = '{$_ID}'";

			pods_query( $sql, false );
		}

		// Comment Meta
		if ( ! empty( PodsMeta::$comment ) ) {
			$sql = "
                DELETE `rel`
                FROM `@wp_commentmeta` AS `rel`
                LEFT JOIN `{$wpdb->posts}` AS `p`
                    ON
                        `p`.`post_type` = '_pods_field'
                LEFT JOIN `{$wpdb->postmeta}` AS `pm`
                    ON
                        `pm`.`post_id` = `p`.`ID`
                        AND `pm`.`meta_key` = 'type'
                        AND `pm`.`meta_value` IN ( {$file_types} )
                WHERE
                    `p`.`ID` IS NOT NULL
                    AND `pm`.`meta_id` IS NOT NULL
                    AND `rel`.`meta_key` = `p`.`post_name`
                    AND `rel`.`meta_value` = '{$_ID}'";

			pods_query( $sql, false );
		}
	}
1213474
public static function get_related_posts_query( $post_id ) {
		$_post = get_post( $post_id );

		if ( ! isset( $_post->ID ) ) {
			return;
		}

		$tax_query = [];

		$taxonomies = get_object_taxonomies( get_post_type( $post_id ), 'object' );
		foreach ( $taxonomies as $taxonomy ) {
			if ( false === $taxonomy->public || false === $taxonomy->show_ui ) {
				continue;
			}

			$term_ids = wp_get_object_terms( $post_id, $taxonomy->name, [ 'fields' => 'ids' ] );
			if ( ! $term_ids ) {
				continue;
			}

			$tax_query[] = [
				'taxonomy' => $taxonomy->name,
				'field'    => 'term_id',
				'terms'    => $term_ids,
				'operator' => 'IN',
			];
		}

		$related_posts_args = [
			'post_type'      => get_post_type( $post_id ),
			'posts_per_page' => 4,
			'orderby'        => 'rand',
			'post__not_in'   => [ $post_id ],
			'tax_query'      => array_merge(
				[
					'relation' => 'AND',
				],
				$tax_query
			),
		];

		$related_posts_args = apply_filters( 'mimizuku_related_posts_args', $related_posts_args );

		return new \WP_Query(
			array_merge(
				$related_posts_args,
				[
					'ignore_sticky_posts' => true,
					'no_found_rows'       => true,
					'suppress_filters'    => true,
				]
			)
		);
	}
930952
public function retrieveSectionMetadata( $section_id, $post_type ) {
		if ( in_array( $post_type, [ 'front-matter', 'back-matter' ], true ) ) {
			foreach ( $this->sourceBookStructure[ $post_type ] as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $v['metadata'];
				}
			}
		} elseif ( $post_type === 'chapter' ) {
			foreach ( $this->sourceBookStructure['parts'] as $key => $part ) {
				foreach ( $part['chapters'] as $k => $v ) {
					if ( $v['id'] === absint( $section_id ) ) {
						return $v['metadata'];
					}
				}
			}
		} elseif ( $post_type === 'glossary ' ) {
			foreach ( $this->sourceBookGlossary as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $v['metadata'];
				}
			}
		}
		return []; // Nothing was found
	}
1134050
public void clearPostTerms(final long postId, final String taxonomy) throws SQLException {
      List<TaxonomyTerm> terms = selectPostTerms(postId, taxonomy);
      for(TaxonomyTerm term : terms) {
         clearPostTerm(postId, term.id);
      }
   }