// Call setslug() only when: // * a published post slug is changed // * a draft post title is changed // * a draft post slug is changed if ( $this->status == Post::status( 'published' ) ) { if ( ( isset( $this->newfields['slug'] ) && $this->newfields['slug'] != '' ) && ( $this->fields['slug'] != $this->newfields['slug'] ) ){ $this->setslug(); } } elseif ( $this->status == Post::status( 'draft' ) ) { if ( ( $this->newfields['slug'] == '' ) || ( $this->newfields['title'] != $this->fields['title'] ) ) { $this->setslug(); } }