Skip to content

Commit 445f8a5

Browse files
committed
feat: Update admin classes and assets for improved functionality and consistency
1 parent 2781a3d commit 445f8a5

5 files changed

Lines changed: 19 additions & 15 deletions

File tree

plugin/includes/admin/class-cof-admin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function add_menu_pages() {
6363
'manage_options',
6464
'codeideal-open-fields',
6565
array( $this, 'render_main_page' ),
66-
'dashicons-forms',
66+
'dashicons-editor-table',
6767
30
6868
);
6969

@@ -87,7 +87,7 @@ public function add_menu_pages() {
8787
*/
8888
public function render_main_page() {
8989
?>
90-
<div id="cof-admin" class="cof-admin-wrap">
90+
<div id="openfields-admin" class="cof-admin-wrap">
9191
<div class="cof-loading">
9292
<span class="spinner is-active"></span>
9393
<?php esc_html_e( 'Loading Open Fields...', 'codeideal-open-fields' ); ?>
@@ -109,7 +109,7 @@ public function enqueue_loading_styles( $hook ) {
109109
}
110110

111111
$inline_css = '
112-
#cof-admin {
112+
#openfields-admin {
113113
margin: 0;
114114
}
115115
.cof-loading {

plugin/includes/admin/class-cof-meta-box.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,8 @@ private function render_term_field( $field, $term_id ) {
955955
$meta_key = self::META_PREFIX . $field->name;
956956
$value = $term_id ? get_term_meta( $term_id, $meta_key, true ) : '';
957957

958-
// Use default value if no saved value.
959-
if ( empty( $value ) && ! empty( $field->default_value ) ) {
958+
// Use default value if meta doesn't exist yet.
959+
if ( $term_id && ! metadata_exists( 'term', $term_id, $meta_key ) && ! empty( $field->default_value ) ) {
960960
$value = $field->default_value;
961961
}
962962

@@ -1308,8 +1308,8 @@ private function render_user_field( $field, $user_id ) {
13081308
$meta_key = self::META_PREFIX . $field->name;
13091309
$value = $user_id ? get_user_meta( $user_id, $meta_key, true ) : '';
13101310

1311-
// Use default value if no saved value.
1312-
if ( empty( $value ) && ! empty( $field->default_value ) ) {
1311+
// Use default value if meta doesn't exist yet.
1312+
if ( $user_id && ! metadata_exists( 'user', $user_id, $meta_key ) && ! empty( $field->default_value ) ) {
13131313
$value = $field->default_value;
13141314
}
13151315

plugin/includes/class-cof-assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function meta_box_scripts( $hook ) {
171171

172172
// Localize script data.
173173
wp_localize_script(
174-
'cof-meta-box',
174+
'cof-fields',
175175
'cofMetaBox',
176176
array(
177177
'i18n' => array(

plugin/includes/class-cof-installer.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static function activate() {
3737
self::create_options();
3838
self::set_version();
3939

40-
// Clear the permalinks.
41-
flush_rewrite_rules();
40+
// Set transient for activation redirect.
41+
set_transient( 'cof_activation_redirect', 1, 30 );
4242

4343
/**
4444
* Fires after plugin activation.
@@ -54,11 +54,8 @@ public static function activate() {
5454
* @since 1.0.0
5555
*/
5656
public static function deactivate() {
57-
// Clear scheduled hooks.
58-
wp_clear_scheduled_hook( 'cof_daily_cleanup' );
59-
60-
// Clear the permalinks.
61-
flush_rewrite_rules();
57+
// Delete activation redirect transient.
58+
delete_transient( 'cof_activation_redirect' );
6259

6360
/**
6461
* Fires after plugin deactivation.

plugin/includes/class-cof.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ private function init_hooks() {
102102
* @since 1.0.0
103103
*/
104104
public function init() {
105+
// Load plugin text domain for translations.
106+
load_plugin_textdomain(
107+
'codeideal-open-fields',
108+
false,
109+
dirname( COF_PLUGIN_BASENAME ) . '/languages'
110+
);
111+
105112
// Initialize components.
106113
COF_Assets::instance();
107114
COF_Field_Registry::instance();

0 commit comments

Comments
 (0)