parent = $parent; $this->base = 'dkpdf_'; // Initialise settings add_action( 'init', array( $this, 'init_settings' ), 11 ); // Register plugin settings add_action( 'admin_init' , array( $this, 'register_settings' ) ); // Add settings page to menu add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); // Add settings link to plugins page add_filter( 'plugin_action_links_' . plugin_basename( DKPDF_PLUGIN_FILE ) , array( $this, 'add_settings_link' ) ); } /** * Initialise settings * @return void */ public function init_settings () { $this->settings = $this->settings_fields(); } /** * Adds DK PDF admin menu * @return void */ public function add_menu_item () { // main menu $page = add_menu_page( 'DK PDF', 'DK PDF', 'manage_options', 'dkpdf' . '_settings', array( $this, 'settings_page' ) ); // Addons submenu add_submenu_page( 'dkpdf' . '_settings', 'Addons', 'Addons', 'manage_options', 'dkpdf-addons', array( $this, 'dkpdf_addons_screen' )); // support add_submenu_page( 'dkpdf' . '_settings', 'Support', 'Support', 'manage_options', 'dkpdf-support', array( $this, 'dkpdf_support_screen' )); // settings assets add_action( 'admin_print_styles-' . $page, array( $this, 'settings_assets' ) ); } public function dkpdf_support_screen() { ?>

DK PDF Support

Documentation

Everything you need to know for getting DK PDF up and running.

Go to Documentation

Support

Having trouble? don't worry, create a ticket in the support forum.

Go to Support

DK PDF Addons

DK PDF Generator

Allows creating PDF documents with your selected WordPress content, also allows adding a Cover and a Table of contents.

Go to DK PDF Generator

' . __( 'Settings', 'dkpdf' ) . ''; array_push( $links, $settings_link ); return $links; } /** * Build settings fields * @return array Fields to be displayed on settings page */ private function settings_fields () { $post_types_arr = dkpdf_get_post_types(); // pdf button settings $settings['pdfbtn'] = array( 'title' => __( 'PDF Button', 'dkpdf' ), 'description' => '', 'fields' => array( array( 'id' => 'pdfbutton_text', 'label' => __( 'Button text' , 'dkpdf' ), 'description' => '', 'type' => 'text', 'default' => 'PDF Button', 'placeholder' => '' ), array( 'id' => 'pdfbutton_post_types', 'label' => __( 'Post types to apply:', 'dkpdf' ), 'description' => '', 'type' => 'checkbox_multi', 'options' => $post_types_arr, 'default' => array() ), array( 'id' => 'pdfbutton_action', 'label' => __( 'Action', 'dkpdf' ), 'description' => '', 'type' => 'radio', 'options' => array( 'open' => 'Open PDF in new Window', 'download' => 'Download PDF directly' ), 'default' => 'open' ), array( 'id' => 'pdfbutton_position', 'label' => __( 'Position', 'dkpdf' ), 'description' => '', 'type' => 'radio', 'options' => array( 'shortcode' => 'Use shortcode', 'before' => 'Before content', 'after' => 'After content' ), 'default' => 'before' ), array( 'id' => 'pdfbutton_align', 'label' => __( 'Align', 'dkpdf' ), 'description' => '', 'type' => 'radio', 'options' => array( 'left' => 'Left', 'center' => 'Center', 'right' => 'Right' ), 'default' => 'right' ), ) ); // pdf setup $settings['dkpdf_setup'] = array( 'title' => __( 'PDF Setup', 'dkpdfg' ), 'description' => '', 'fields' => array( array( 'id' => 'page_orientation', 'label' => __( 'Page orientation', 'dkpdfg' ), 'description' => '', 'type' => 'radio', 'options' => array( 'vertical' => 'Vertical', 'horizontal' => 'Horizontal' ), 'default' => 'vertical' ), array( 'id' => 'font_size', 'label' => __( 'Font size', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '12', 'placeholder' => '12' ), array( 'id' => 'margin_left', 'label' => __( 'Margin left', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '15', 'placeholder' => '15' ), array( 'id' => 'margin_right', 'label' => __( 'Margin right', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '15', 'placeholder' => '15' ), array( 'id' => 'margin_top', 'label' => __( 'Margin top', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '50', 'placeholder' => '50' ), array( 'id' => 'margin_bottom', 'label' => __( 'Margin bottom', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '30', 'placeholder' => '30' ), array( 'id' => 'margin_header', 'label' => __( 'Margin header', 'dkpdfg' ), 'description' => 'In points (pt)', 'type' => 'number', 'default' => '15', 'placeholder' => '15' ), ) ); // header & footer settings $settings['pdf_header_footer'] = array( 'title' => __( 'PDF Header & Footer', 'dkpdf' ), 'description' => '', 'fields' => array( array( 'id' => 'pdf_header_image', 'label' => __( 'Header logo' , 'dkpdf' ), 'description' => '', 'type' => 'image', 'default' => '', 'placeholder' => '' ), array( 'id' => 'pdf_header_show_title', 'label' => __( 'Header show title', 'dkpdf' ), 'description' => '', 'type' => 'checkbox', 'default' => '' ), array( 'id' => 'pdf_header_show_pagination', 'label' => __( 'Header show pagination', 'dkpdf' ), 'description' => '', 'type' => 'checkbox', 'default' => '' ), array( 'id' => 'pdf_footer_text', 'label' => __( 'Footer text' , 'dkpdf' ), 'description' => __( 'HTML tags: a, br, em, strong, hr, p, h1 to h4', 'dkpdf' ), 'type' => 'textarea', 'default' => '', 'placeholder' => '' ), array( 'id' => 'pdf_footer_show_title', 'label' => __( 'Footer show title', 'dkpdf' ), 'description' => '', 'type' => 'checkbox', 'default' => '' ), array( 'id' => 'pdf_footer_show_pagination', 'label' => __( 'Footer show pagination', 'dkpdf' ), 'description' => '', 'type' => 'checkbox', 'default' => '' ), ) ); // style settings $settings['pdf_css'] = array( 'title' => __( 'PDF CSS', 'dkpdf' ), 'description' => '', 'fields' => array( array( 'id' => 'pdf_custom_css', 'label' => __( 'PDF Custom CSS' , 'dkpdf' ), 'description' => __( '', 'dkpdf' ), 'type' => 'textarea_code', 'default' => '', 'placeholder' => '' ), array( 'id' => 'print_wp_head', 'label' => __( 'Use your enqueued theme and plugin CSS', 'dkpdf' ), 'description' => __( 'Adds wp_head() in PDF head', 'dkpdf' ), 'type' => 'checkbox', 'default' => '' ), ) ); $settings = apply_filters( 'dkpdf' . '_settings_fields', $settings ); return $settings; } /** * Register plugin settings * @return void */ public function register_settings () { if ( is_array( $this->settings ) ) { // Check posted/selected tab $current_section = ''; if ( isset( $_POST['tab'] ) && $_POST['tab'] ) { $current_section = $_POST['tab']; } else { if ( isset( $_GET['tab'] ) && $_GET['tab'] ) { $current_section = $_GET['tab']; } } foreach ( $this->settings as $section => $data ) { if ( $current_section && $current_section != $section ) continue; // Add section to page add_settings_section( $section, $data['title'], array( $this, 'settings_section' ), 'dkpdf' . '_settings' ); foreach ( $data['fields'] as $field ) { // Validation callback for field $validation = ''; if ( isset( $field['callback'] ) ) { $validation = $field['callback']; } // Register field $option_name = $this->base . $field['id']; register_setting( 'dkpdf' . '_settings', $option_name, $validation ); // Add field to page add_settings_field( $field['id'], $field['label'], array( $this->parent->admin, 'display_field' ), 'dkpdf' . '_settings', $section, array( 'field' => $field, 'prefix' => $this->base ) ); } if ( ! $current_section ) break; } } } public function settings_section ( $section ) { $html = '

' . $this->settings[ $section['id'] ]['description'] . '

' . "\n"; echo $html; } /** * Load settings page content * @return void */ public function settings_page () { if( isset( $_GET['settings-updated']) ) { ?>

' . "\n"; $html .= '

' . __( 'DK PDF Settings' , 'dkpdf' ) . '

' . "\n"; $tab = ''; if ( isset( $_GET['tab'] ) && $_GET['tab'] ) { $tab .= $_GET['tab']; } // Show page tabs if ( is_array( $this->settings ) && 1 < count( $this->settings ) ) { $html .= '' . "\n"; } $html .= '
' . "\n"; // Get settings fields ob_start(); settings_fields( 'dkpdf' . '_settings' ); do_settings_sections( 'dkpdf' . '_settings' ); $html .= ob_get_clean(); $html .= '

' . "\n"; $html .= '' . "\n"; $html .= '' . "\n"; $html .= '

' . "\n"; $html .= '
' . "\n"; $html .= '' . "\n"; echo $html; } /** * Main DKPDF_Settings Instance */ public static function instance ( $parent ) { if ( is_null( self::$_instance ) ) { self::$_instance = new self( $parent ); } return self::$_instance; } // End instance() /** * Cloning is forbidden. */ public function __clone () { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), $this->parent->_version ); } // End __clone() /** * Unserializing instances of this class is forbidden. */ public function __wakeup () { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), $this->parent->_version ); } // End __wakeup() }