admin = $admin;
$this->taxonomy = $taxonomy;
add_action( $this->taxonomy.'_add_form_fields', array ( $this, 'addImage' ), 10, 2 );
add_action( 'created_'.$this->taxonomy, array ( $this, 'saveImage' ), 10, 2 );
add_action( $this->taxonomy.'_edit_form_fields', array ( $this, 'updateImage' ), 10, 2 );
add_action( 'edited_'.$this->taxonomy, array ( $this, 'updatedImage' ), 10, 2 );
}
/**
* @param Admin $admin
* @param $taxonomy
*
* @return TermMeta|null
*/
public static function getInstance(Admin $admin, $taxonomy) {
if(is_null(self::$instance)) {
self::$instance = new self($admin, $taxonomy);
}
return self::$instance;
}
/**
* @param $taxonomy
*/
public function addImage ( $taxonomy ) {
$pinWidth = $this->admin->getOption( 'assl_pin_size_width', 'assl_admin_map' );
$pinHeight = $this->admin->getOption( 'assl_pin_size_height', 'assl_admin_map' );
?>
addScript();
}
/**
* @param $term_id
* @param $tt_id
*/
public function saveImage ( $term_id, $tt_id ) {
if( isset( $_POST[$this->termMetaKey] ) && '' !== $_POST[$this->termMetaKey] ){
$image = $_POST[$this->termMetaKey];
add_term_meta( $term_id, $this->termMetaKey, $image, true );
}
}
/**
* @param $term
* @param $taxonomy
*/
public function updateImage ( $term, $taxonomy ) {
$pinWidth = $this->admin->getOption( 'assl_pin_size_width', 'assl_admin_map' );
$pinHeight = $this->admin->getOption( 'assl_pin_size_height', 'assl_admin_map' );
?>
|
|
term_id, $this->termMetaKey, true );
//Compatibilità con il vecchio plugin
if(is_array($image)) {
$image_id = $image['id'];
} else {
$image_id = $image;
}
?>
PNG ( x px)
|
addScript();
}
/**
* @param $term_id
* @param $tt_id
*/
public function updatedImage ( $term_id, $tt_id ) {
if( isset( $_POST[$this->termMetaKey] ) && '' !== $_POST[$this->termMetaKey] ){
$image = $_POST[$this->termMetaKey];
update_term_meta( $term_id, $this->termMetaKey, $image );
} else {
update_term_meta( $term_id, $this->termMetaKey, '' );
}
}
/**
*
*/
public function addScript() { ?>