load_dashicons(); } /** * @since 1.0 */ function init( $cpac ) { $this->cpac = $cpac; } /** * Enqueue admin styles and scripts * * @since 1.0 */ public function admin_scripts() { wp_register_style( 'cpacic-admin-cpac-settings', plugins_url( 'assets/css/admin/cpac-settings.css', __FILE__ ) ); wp_register_script( 'cpacic-admin-cpac-settings', plugins_url( 'assets/js/admin/cpac-settings.js', __FILE__ ), array( 'jquery' ) ); if ( $this->cpac && $this->cpac->is_settings_screen() ) { wp_enqueue_style( 'cpacic-admin-cpac-settings' ); wp_enqueue_script( 'cpacic-admin-cpac-settings' ); wp_enqueue_media(); } } /** * @since 1.0 */ public function column_default_options( $options ) { $options['label_icon_dashicon_name'] = ''; $options['label_icon_custom_url'] = ''; $options['label_icon_attachment_id'] = ''; $options['label_icon_type'] = ''; return $options; } /** * @since 1.1 */ public function load_dashicons() { if ( empty( $this->dashicons ) ) { $fname = plugin_dir_path( __FILE__ ) . 'data/icons.json'; $fh = fopen( $fname, 'r' ); $contents = ''; while ( ! feof( $fh ) ) { $line = fgets( $fh ); $contents .= $line; } $this->dashicons = json_decode( $contents ); } } /** * @since 1.0 */ public function column_settings_fields( $column_instance ) { $type = $column_instance->options->label_icon_type; $icon_dashicon_name = $column_instance->options->label_icon_dashicon_name; $icon_custom_url = $column_instance->options->label_icon_custom_url; $icon_attachment_id = $column_instance->options->label_icon_attachment_id; // Backwards compatibility with 1.0 // In 1.0, a single column setting was used to store the custom URL and the attachment ID, dependent on // the column type. In 1.1, this was replaced by storing all separately if ( ! empty( $column_instance->options->label_icon ) ) { if ( $type == 'attachment' && ! $icon_attachment_id ) { $icon_attachment_id = $column_instance->options->label_icon; } if ( $type == 'custom' && ! $icon_custom_url ) { $icon_custom_url = $column_instance->options->label_icon; } } ?>