delete a custom taxonomy
556784
public function delete_custom_taxonomy(){
    global $wpdb;

    //checking the nonce
    check_admin_referer('delete_custom_taxonomy_mf_custom_taxonomy');

    if( isset($_GET['custom_taxonomy_id']) ){
      $id = (int)$_GET['custom_taxonomy_id'];

      if( is_int($id) ){
        $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_TAXONOMY." WHERE id = %d",$id );
        $wpdb->query($sql);
        $this->mf_redirect(null,null,array('message' => 'success'));
      }
    }
  }
317924
protected function _deleteObject( $term_id ) {
		$term = get_term_by( 'id', $term_id, $this->_taxonomy );
		if ( ! $term || is_wp_error( $term ) ) {
			return false;
		}

		$deleted = wp_delete_term( $term_id, $this->_taxonomy );
		if ( $deleted && ! is_wp_error( $deleted ) ) {
			$this->_debug( 'Deleted term with ID: ' . $term_id );
			return true;
		} elseif ( is_wp_error( $deleted ) ) {
			$this->_debug(
				'Removal failed for term %d with message [%s] %s',
				$term_id,
				$deleted->get_error_code(),
				$deleted->get_error_message()
			);
		} else {
			$this->_debug( 'Term removal failed for ID: ' . $term_id );
		}

		return false;
	}
190047
public function delete($id)
    {
        $this->loadModel('Taxonomy.Terms');
        $term = $this->Terms->get($id);
        $this->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $term->vocabulary_id]]);
        $this->Terms->removeFromTree($term);

        if ($this->Terms->delete($term)) {
            $this->Flash->success(__d('taxonomy', 'Term successfully removed!'));
        } else {
            $this->Flash->danger(__d('taxonomy', 'Term could not be removed, please try again'));
        }

        $this->title(__d('taxonomy', 'Delete Term'));
        $this->redirect($this->referer());
    }
540729
def delete(self, **kwargs):
        
        self.reload_context(es_based=False, **kwargs)
        return super(ESCollectionView, self).delete(**kwargs)
706124
function delete() {
			$this->_data = array();

			$all_data = $this->get_all_data();
			unset( $all_data[ $this->_secondary_id ] );
			$options_manager = $this->get_option_manager();
			$options_manager->set_option( $this->_id, $all_data, true );
		}
436762
def remove_custom_binding(self, key_name, needs_prefix=False):
        
        k = (needs_prefix, key_name)

        if k in self.custom_bindings:
            self.custom_key_bindings.remove(self.custom_bindings[k].handler)
            del self.custom_bindings[k]
136019
public function delete()
	{
		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Get items to remove from the request.
		$cid = $this->input->get('cid', array(), 'array');
		$extension = $this->input->getCmd('extension', null);

		if (!is_array($cid) || count($cid) < 1)
		{
			JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
		}
		else
		{
			// Get the model.
			/** @var CategoriesModelCategory $model */
			$model = $this->getModel();

			// Make sure the item ids are integers
			$cid = ArrayHelper::toInteger($cid);

			// Remove the items.
			if ($model->delete($cid))
			{
				$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
			}
			else
			{
				$this->setMessage($model->getError());
			}
		}

		$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&extension=' . $extension, false));
	}
154570
def delete_metadata(self, href=None):
        """"""

        # Argument error checking.
        assert href is not None

        raw_result = self.delete(href)

        if raw_result.status != 204:
            raise APIException(raw_result.status, raw_result.json)
34579
public function delete_definition() {
        global $DB;

        if (!$this->is_form_defined()) {
            // nothing to do
            return;
        }

        // firstly, let the plugin delete everything from their own tables
        $this->delete_plugin_definition();
        // then, delete all instances left
        $DB->delete_records('grading_instances', array('definitionid' => $this->definition->id));
        // finally, delete the main definition record
        $DB->delete_records('grading_definitions', array('id' => $this->definition->id));

        $this->definition = false;
    }
452888
public function uninstall(){
    global $wpdb;

    self::clear_cache();
    self::delete_files();
    delete_option(MF_SETTINGS_KEY);
    //DB version
    delete_option(MF_DB_VERSION_KEY);

    $sql = "DELETE a.* FROM $wpdb->postmeta AS a, ".MF_TABLE_POST_META." AS b WHERE b.meta_id = a.meta_id";
    $wpdb->query($sql);

    $sql = "DROP TABLE " . MF_TABLE_POSTTYPES;
    $wpdb->query($sql);
    
    $sql = "DROP TABLE " . MF_TABLE_CUSTOM_TAXONOMY;
    $wpdb->query($sql);
    
    $sql = "DROP TABLE " . MF_TABLE_CUSTOM_FIELDS;
    $wpdb->query($sql);

    $sql = "DROP TABLE " . MF_TABLE_CUSTOM_GROUPS;
    $wpdb->query($sql);

    $sql = "DROP TABLE " . MF_TABLE_POST_META;
    $wpdb->query($sql);
    
    $current = get_option('active_plugins');
    $plugin = plugin_basename(MF_PATH.'/main.php');
    array_splice($current, array_search( $plugin, $current), 1 );
    do_action('deactivate_' . trim( $plugin ));
    update_option('active_plugins', $current);

    wp_redirect('options-general.php');
  }
575845
public function uninstall_cleanup() {
        global $DB;
        $DB->delete_records_select('customfield_data',
            'fieldid IN (SELECT f.id FROM {customfield_field} f WHERE f.type = ?)', [$this->name]);
        $DB->delete_records('customfield_field', ['type' => $this->name]);
        parent::uninstall_cleanup();
    }
154218
def delete_term(set_id, term_id, access_token):
    """"""
    api_call('delete', 'sets/{}/terms/{}'.format(set_id, term_id), access_token=access_token)
1135305
def delete_custom_public_read_api(
        request,
        database_name,
        collection_name,
        slug):
    """"""
    ss = get_object_or_404(CustomPublicReadAPI, datbase_name=database_name,
                           collection_name=collection_name, slug=slug)
    ss.delete()
    messages.success(request, _("Custom Public Read API deleted."))
    return HttpResponseRedirect(
        reverse('djmongo_show_apis',
                args=(ss.database_name, ss.collection_name)))
678781
public function delete()
	{
		if ( ! $this->is_loaded() ) return false;

		$error = wp_delete_post( $this->attributes['ID'], $this->forceDelete );

		return $error !== false;
	}
180694
public function uninstall_cleanup() {
        global $DB;

        // Find all definitions and templates.
        $definitions = $DB->get_fieldset_select('grading_definitions', 'id', 'method = ?', [$this->name]);
        if ($definitions) {
            // Delete instances and definitions. Deleting instance will not delete grades because they were
            // already pushed to the module and gradebook.
            list($sqld, $paramsd) = $DB->get_in_or_equal($definitions);
            $DB->delete_records_select('grading_instances', 'definitionid ' . $sqld, $paramsd);
            $DB->delete_records_select('grading_definitions', 'id ' . $sqld, $paramsd);
        }
        // Delete templates for this grading method.
        $DB->delete_records_select('grading_areas', 'component = ? AND activemethod = ?', array('core_grading', $this->name));
        // Update the remaining grading areas to use simple grading method instead of this grading method.
        $DB->execute('UPDATE {grading_areas} SET activemethod = NULL WHERE activemethod = ?', [$this->name]);

        parent::uninstall_cleanup();
    }
324511
public function removeCategoryDuplicates() {
    $this->output->writeln(dt('Cleaning all commerce categories, please wait...'));

    $db = $this->connection;

    /** @var \Drupal\taxonomy\TermStorageInterface $termStorage */
    $termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');

    /** @var \Drupal\node\NodeStorageInterface $nodeStorage */
    $nodeStorage = \Drupal::entityTypeManager()->getStorage('node');

    $query = $db->select('taxonomy_term__field_commerce_id', 'ttfci');
    $query->addField('ttfci', 'field_commerce_id_value', 'commerce_id');
    $query->groupBy('commerce_id');
    $query->having('count(*) > 1');
    $result = $query->execute()->fetchAllKeyed(0, 0);

    if (empty($result)) {
      $this->output->writeln(dt('No duplicate categories found.'));
      return;
    }

    foreach ($result as $commerce_id) {
      $this->output->writeln(dt('Duplicate categories found for commerce id: @commerce_id.', [
        '@commerce_id' => $commerce_id,
      ]));

      $query = $db->select('taxonomy_term__field_commerce_id', 'ttfci');
      $query->addField('ttfci', 'entity_id', 'tid');
      $query->condition('ttfci.field_commerce_id_value', $commerce_id);
      $query->orderBy('tid', 'DESC');
      $tids = $query->execute()->fetchAllKeyed(0, 0);

      foreach ($tids as $tid) {
        $query = $nodeStorage->getQuery();
        $query->condition('field_category', $tid);
        $nodes = $query->execute();

        if (empty($nodes)) {
          $this->output->writeln(dt('No nodes found for tid: @tid for commerce id: @commerce_id. Deleting', [
            '@commerce_id' => $commerce_id,
            '@tid' => $tid,
          ]));

          $term = $termStorage->load($tid);
          $term->delete();

          unset($tids[$tid]);

          // Break the loop if only one left now, we might not have any products
          // added yet and categories are synced which means there will be no
          // nodes for any term.
          if (count($tids) == 1) {
            break;
          }
        }
        else {
          $this->output->writeln(dt('@count nodes found for tid: @tid for commerce id: @commerce_id. Not Deleting', [
            '@commerce_id' => $commerce_id,
            '@tid' => $tid,
            '@count' => count($nodes),
          ]));
        }
      }
    }

    $this->output->writeln(dt('Done.'));
  }
670975
public static function delete_type($extension) {
        // Extension must exist.
        $mimetypes = get_mimetypes_array();
        if (!array_key_exists($extension, $mimetypes)) {
            throw new coding_exception('Extension ' . $extension . ' not found');
        }

        // Get existing custom filetype list.
        $customs = self::get_custom_types();

        // Remove any entries for this extension.
        foreach ($customs as $key => $custom) {
            if ($custom->extension === $extension && empty($custom->deleted)) {
                unset($customs[$key]);
            }
        }

        // If it was a standard entry (doesn't have 'custom' set) then add a
        // deleted marker.
        if (empty($mimetypes[$extension]['custom'])) {
            $customs[] = (object)array('extension' => $extension, 'deleted' => true);
        }

        // Save and reset cache.
        self::set_custom_types($customs);
    }