save a custom taxonomy
178489
public function save_custom_taxonomy(){
    global $mf_domain;

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

    if(isset($_POST['mf_custom_taxonomy'])){
      //check custom_taxonomy_id
      $mf = $_POST['mf_custom_taxonomy'];
      if($mf['core']['id']){
        $this->update_custom_taxonomy($mf);
      }else{
        if($this->new_custom_taxonomy($mf)){
          //redirect to dashboard
        }else{
          //reload form and show warning
        }
      }
    }
    $this->mf_redirect(null,null,array('message' => 'success'));
  }
718103
protected function __save()
    {
        $this->parseDate();
        foreach($this->records as $record)
        {
            FileUtil::writeFile($this->getFileName(), $this->getLogString($record) . PHP_EOL, FILE_APPEND);
        }
    }
290245
public function getTaxonomyValues()
    {
        if (!isset($_POST['tax']) || empty($_POST['tax'])) {
            echo '0';
            die();
        }

        $taxonomy = $_POST['tax'];
        $post = $_POST['post'];

        $result = array(
            'tax' => get_terms($taxonomy, array(
                'hide_empty' => false,
            )),
            'curr' => get_field('posts_taxonomy_value', $post)
        );

        echo json_encode($result);
        die();
    }
24770
protected function saveCategories()
    {
        $nextEntityId = $this->resourceHelper->getNextAutoincrement($this->entityTable);
        static $entityId;

        while ($bunch = $this->_dataSourceModel->getNextBunch()) {
            $entityRowsIn = [];
            $entityRowsUp = [];
            $attributes = [];
            $uploadedGalleryFiles = [];

            foreach ($bunch as $rowNum => $rowData) {
                if (!$this->validateRow($rowData, $rowNum)) {
                    continue;
                }
                $rowScope = $this->getRowScope($rowData);

                $rowData = $this->_prepareRowForDb($rowData);
                $this->filterRowData($rowData);

                if (self::SCOPE_DEFAULT == $rowScope) {
                    $parentCategory = $this->getParentCategory($rowData);

                    $time = !empty($rowData[CategoryModel::KEY_CREATED_AT]) ? strtotime($rowData[CategoryModel::KEY_CREATED_AT]) : null;

                    // entity table data
                    $entityRow = [
                        CategoryModel::KEY_PARENT_ID => $parentCategory['entity_id'],
                        CategoryModel::KEY_LEVEL => $parentCategory[CategoryModel::KEY_LEVEL] + 1,
                        CategoryModel::KEY_CREATED_AT => (new \DateTime($time))->format(DateTime::DATETIME_PHP_FORMAT),
                        CategoryModel::KEY_UPDATED_AT => "now()",
                        CategoryModel::KEY_POSITION => $rowData[CategoryModel::KEY_POSITION]
                    ];

                    if (isset($this->categoriesWithRoots[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]])) { //edit
                        $entityId = $this->categoriesWithRoots[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]]['entity_id'];
                        $entityRow['entity_id'] = $entityId;
                        $entityRow[CategoryModel::KEY_PATH] = $parentCategory[CategoryModel::KEY_PATH] . '/' . $entityId;
                        $entityRowsUp[] = $entityRow;
                        $rowData['entity_id'] = $entityId;

                    } else { // create
                        $entityId = $nextEntityId++;
                        $entityRow['entity_id'] = $entityId;
                        $entityRow[CategoryModel::KEY_PATH] = $parentCategory[CategoryModel::KEY_PATH] . '/' . $entityId;
                        $entityRow['attribute_set_id'] = $this->defaultAttributeSetId;
                        $entityRowsIn[] = $entityRow;

                        $this->newCategory[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]] = [
                            'entity_id' => $entityId,
                            CategoryModel::KEY_PATH => $entityRow[CategoryModel::KEY_PATH],
                            CategoryModel::KEY_LEVEL => $entityRow[CategoryModel::KEY_LEVEL]
                        ];
                    }
                }

                foreach ($this->imagesArrayKeys as $imageCol) {
                    if (!empty($rowData[$imageCol])) { // 5. Media gallery phase
                        if (!array_key_exists($rowData[$imageCol], $uploadedGalleryFiles)) {
                            $uploadedGalleryFiles[$rowData[$imageCol]] = $this->uploadMediaFiles($rowData[$imageCol]);
                        }
                        $rowData[$imageCol] = $uploadedGalleryFiles[$rowData[$imageCol]];
                    }
                }

                // Attributes phase
                $rowStore = self::SCOPE_STORE == $rowScope ? $this->storeCodeToId[$rowData[self::COL_STORE]] : 0;

                /** @var $category \Magento\Catalog\Model\Category */
                $category = $this->defaultCategory->setData($rowData);

                foreach (array_intersect_key($rowData, $this->attributes) as $attrCode => $attrValue) {
                    if (!$this->attributes[$attrCode]['is_static']) {

                        /** @var \Magento\Eav\Model\Entity\Attribute $attribute */
                        $attribute = $this->attributes[$attrCode]['attribute'];

                        if ('multiselect' != $attribute->getFrontendInput()
                            && self::SCOPE_NULL == $rowScope
                        ) {
                            continue; // skip attribute processing for SCOPE_NULL rows
                        }

                        $attrId = $attribute->getAttributeId();
                        $backModel = $attribute->getBackendModel();
                        $attrTable = $attribute->getBackend()->getTable();
                        $attrParams = $this->attributes[$attrCode];
                        $storeIds = [0];

                        if ('select' == $attrParams['type']) {
                            if (isset($attrParams['options'][strtolower($attrValue)])) {
                                $attrValue = $attrParams['options'][strtolower($attrValue)];
                            }
                        } elseif ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
                            $attrValue = (new \DateTime(strtotime($attrValue)))->format(DateTime::DATETIME_PHP_FORMAT);
                        } elseif ($backModel && 'available_sort_by' != $attrCode) {
                            $attribute->getBackend()->beforeSave($category);
                            $attrValue = $category->getData($attribute->getAttributeCode());
                        }

                        if (self::SCOPE_STORE == $rowScope) {
                            if (self::SCOPE_WEBSITE == $attribute->getData('is_global')) {
                                // check website defaults already set
                                if (!isset($attributes[$attrTable][$entityId][$attrId][$rowStore])) {
                                    $storeIds = $this->storeIdToWebsiteStoreIds[$rowStore];
                                }
                            } elseif (self::SCOPE_STORE == $attribute->getData('is_global')) {
                                $storeIds = [$rowStore];
                            }
                        }

                        foreach ($storeIds as $storeId) {
                            if ('multiselect' == $attribute->getFrontendInput()) {
                                if (!isset($attributes[$attrTable][$entityId][$attrId][$storeId])) {
                                    $attributes[$attrTable][$entityId][$attrId][$storeId] = '';
                                } else {
                                    $attributes[$attrTable][$entityId][$attrId][$storeId] .= ',';
                                }
                                $attributes[$attrTable][$entityId][$attrId][$storeId] .= $attrValue;
                            } else {
                                $attributes[$attrTable][$entityId][$attrId][$storeId] = $attrValue;
                            }
                        }

                        $attribute->setBackendModel($backModel); // restore 'backend_model' to avoid 'default' setting
                    }
                }
            }

            $this->saveCategoryEntity($entityRowsIn, $entityRowsUp);
            $this->saveCategoryAttributes($attributes);
        }
        return $this;
    }
243843
static public function init() {
		if ( is_null( self::$instance ) ) {
			$taxonomy = Taxonomy::init();
			self::$instance = new self( $taxonomy );
			self::hooks( self::$instance );
		}
		return self::$instance;
	}
973705
def save(self, *args, **kwargs):
        
        if self.gen_description:
            self.description = strip_tags(self.description_from_content())
        super(MetaData, self).save(*args, **kwargs)
1015933
function register_exisiting_taxonomies() {

        if( is_array( $this->exisiting_taxonomies ) ) {
            foreach( $this->exisiting_taxonomies as $taxonomy_name ) {
                register_taxonomy_for_object_type( $taxonomy_name, $this->post_type_name );
            }
        }
    }
831467
def save_keywords(filename, xml):
    """"""
    tmp_dir = os.path.dirname(filename)
    if not os.path.isdir(tmp_dir):
        os.mkdir(tmp_dir)

    file_desc = open(filename, "w")
    file_desc.write(xml)
    file_desc.close()
634837
protected function saveCustomFields(): bool
    {
        //find the custom field module
        if (!$module = Modules::findFirstByName($this->getSource())) {
            return false;
        }

        //we need a new instane to avoid overwrite
        $reflector = new \ReflectionClass($this);
        $classNameWithNameSpace = $reflector->getNamespaceName() . '\\' . $reflector->getShortName() . 'CustomFields';

        //if all is good now lets get the custom fields and save them
        foreach ($this->customFields as $key => $value) {
            //create a new obj per itration to se can save new info
            $customModel = new $classNameWithNameSpace();

            //validate the custome field by it model
            if ($customField = CustomFields::findFirst(['conditions' => 'name = ?0 and modules_id = ?1', 'bind' => [$key, $module->id]])) {
                //throw new Exception("this custom field doesnt exist");

                $customModel->setCustomId($this->getId());
                $customModel->custom_fields_id = $customField->id;
                $customModel->value = $value;
                $customModel->created_at = date('Y-m-d H:i:s');

                if (!$customModel->save()) {
                    throw new Exception('Custome ' . $key . ' - ' . $this->customModel->getMessages()[0]);
                }
            }
        }

        //clean
        unset($this->customFields);

        return true;
    }
571567
public function save()
    {
        $aModule = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("aModules");

        $aModules = [];
        if ($tmp = json_decode($aModule, true)) {
            foreach ($tmp as $key => $value) {
                $sanitizedKey = str_replace(self::BACKSLASH_REPLACEMENT, "\\", $key);
                $aModules[$sanitizedKey] = $value;
            }
            $oModuleInstaller = oxNew(\OxidEsales\Eshop\Core\Module\ModuleInstaller::class);
            $aModules = $oModuleInstaller->buildModuleChains($aModules);
        }

        \OxidEsales\Eshop\Core\Registry::getConfig()->saveShopConfVar("aarr", "aModules", $aModules);
    }
243880
public function register_taxonomy() {

		if ( true === $this->args['query_var'] ) {
			$query_var = $this->taxonomy;
		} else {
			$query_var = $this->args['query_var'];
		}

		$post_types = get_post_types( [
			'query_var' => $query_var,
		] );

		if ( $query_var && count( $post_types ) ) {
			trigger_error( esc_html( sprintf(
				/* translators: %s: Taxonomy query variable name */
				__( 'Taxonomy query var "%s" clashes with a post type query var of the same name', 'extended-cpts' ),
				$query_var
			) ), E_USER_ERROR );
		} elseif ( in_array( $query_var, [ 'type', 'tab' ], true ) ) {
			trigger_error( esc_html( sprintf(
				/* translators: %s: Taxonomy query variable name */
				__( 'Taxonomy query var "%s" is not allowed', 'extended-cpts' ),
				$query_var
			) ), E_USER_ERROR );
		} else {
			register_taxonomy( $this->taxonomy, $this->object_type, $this->args );
		}

	}
1009441
public function save()
    {
        parent::save();

        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        $soxId = $this->getEditObjectId();

        $aParams = $this->_parseRequestParametersForSave(
            $myConfig->getRequestParameter("editval")
        );

        /** @var \OxidEsales\Eshop\Application\Model\Category $oCategory */
        $oCategory = $this->createCategory();

        if ($soxId != self::NEW_CATEGORY_ID) {
            $this->resetCounter("catArticle", $soxId);
            $this->resetCategoryPictures($oCategory, $aParams, $soxId);
        }

        //Disable editing for derived items
        if ($oCategory->isDerived()) {
            return;
        }

        $oCategory = $this->updateCategoryOnSave($oCategory, $aParams);

        $oCategory->save();

        $this->setEditObjectId($oCategory->getId());
    }
873305
def save(self, filename):
        """"""
        filename = pathlib.Path(filename)
        out = []
        keys = sorted(list(self.keys()))
        for key in keys:
            out.append("[{}]".format(key))
            section = self[key]
            ikeys = list(section.keys())
            ikeys.sort()
            for ikey in ikeys:
                var, val = keyval_typ2str(ikey, section[ikey])
                out.append("{} = {}".format(var, val))
            out.append("")

        with filename.open("w") as f:
            for i in range(len(out)):
                # win-like line endings
                out[i] = out[i]+"\n"
            f.writelines(out)
321398
def save(self):
        

        api = Client.instance().api

        index_details = {
            'type': self.index_type_obj.type_name
        }

        extra_index_attributes = self.index_type_obj.get_extra_attributes()

        for extra_attribute_key in extra_index_attributes:
            extra_attribute_value = extra_index_attributes[extra_attribute_key]
            index_details[extra_attribute_key] = extra_attribute_value

        query_parameters = {
            'collection': self.collection.name,
        }

        result = api.index.post(data=index_details, **query_parameters)

        self.index_type_obj.is_new = result['isNewlyCreated']
        self.index_type_obj.id = result['id']
257792
def save_catalog(self):
        
        if self.input["cmd"] == 'save_catalog':
            try:
                edited_object = dict()
                for i in self.input["form"]["CatalogDatas"]:
                    edited_object[i["catalog_key"]] = {"en": i["en"], "tr": i["tr"]}

                newobj = fixture_bucket.get(self.input["object_key"])
                newobj.data = edited_object
                newobj.store()

                # notify user by passing notify in output object
                self.output["notify"] = "catalog: %s successfully updated." % self.input[
                    "object_key"]
            except:
                raise HTTPError(500, "Form object could not be saved")
        if self.input["cmd"] == 'cancel':
            self.output["notify"] = "catalog: %s canceled." % self.input["object_key"]
1361677
function register_taxonomies() {

        if ( is_array( $this->taxonomy_settings ) ) {

            // Foreach taxonomy registered with the post type.
            foreach ( $this->taxonomy_settings as $taxonomy_name => $options ) {

                // Register the taxonomy if it doesn't exist.
                if ( ! taxonomy_exists( $taxonomy_name ) ) {

                    // Register the taxonomy with Wordpress
                    register_taxonomy( $taxonomy_name, $this->post_type_name, $options );

                } else {

                    // If taxonomy exists, register it later with register_exisiting_taxonomies
                    $this->exisiting_taxonomies[] = $taxonomy_name;
                }
            }
        }
    }
291187
protected function taxonomy_exists( $taxonomy ) {

		$taxonomy_names = get_object_taxonomies( $this->get_object_type() );

		if ( ! in_array( $taxonomy, $taxonomy_names, true ) ) {
			WP_CLI::error( "Invalid taxonomy {$taxonomy}." );
		}
	}