/** * Renders the HTML. * * @return void */ public function render() { /* translators: %s = date format */ $description = esc_html__('Please enter the default post date according to the %s date format.', 'default-post-date'); $date_format = 'YYYY-MM-DD'; ?> <input type="text" id="<?php echo $this->id; ?> " name="<?php echo $this->option->get_name(); ?> " value="<?php echo esc_attr($this->option->get()); ?> " maxlength="10" placeholder="<?php echo $date_format; ?> "> <p class="description"> <?php printf($description, "<code>{$date_format}</code>"); ?> </p> <?php }
/** * Enqueues the script file. * * @wp-hook admin_head-{$hook_suffix} * * @return bool */ public function enqueue() { $option_value = $this->option->get(); if (!$option_value) { return false; } $time = strtotime($option_value); if (!$time) { return false; } $handle = 'default-post-date-admin'; $url = plugin_dir_url($this->file); $file = 'assets/js/admin' . (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min') . '.js'; $path = plugin_dir_path($this->file); $version = filemtime($path . $file); wp_enqueue_script($handle, $url . $file, array('jquery'), $version, true); wp_localize_script($handle, 'defaultPostDateSettings', array('day' => date('d', $time), 'month' => date('m', $time), 'year' => date('Y', $time))); return true; }
/** * @covers tfrommen\DefaultPostDate\Setting\Option::get * @dataProvider provide_get_data * * @param string $expected * @param string $default * @param mixed $option * * @return void */ public function test_get($expected, $default, $option) { $testee = new Testee(); WP_Mock::wpFunction('get_option', array('args' => array(Mockery::type('string'), $default), 'return' => $option)); $this->assertSame($expected, $testee->get()); }
/** * Deletes all plugin options. * * @return void */ private function delete_options() { delete_option($this->version_option_name); delete_option($this->option->get_name()); }