/** * Create the input fields for the custom CSS entry. * * @param array $field The parameters of the defined field. * @param array $item The array of data contained. * * @return mixed/HTML $input The new input field. */ public static function freeform_css_input($field, $item) { // Get the standard field info. $id = GP_Pro_Helper::get_field_id($field); $name = GP_Pro_Helper::get_field_name($field); // Fetch the viewport field. $view = !empty($item['viewport']) ? $item['viewport'] : 'global'; // Get our custom data. $value = self::get_custom_css($view); // Start the field. $input = ''; // Set the field wrappers. $input .= '<div class="gppro-input gppro-freeform-input">'; $input .= '<div class="gppro-input-wrap gppro-freeform-wrap">'; // Show the description above the field. $input .= !empty($item['desc']) ? '<p class="description">' . esc_html($item['desc']) . '</p>' : ''; // Load the textarea itself. $input .= '<textarea name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" class="widefat code css-entry css-global">' . esc_html($value) . '</textarea>'; // Load the viewport button. $input .= '<span data-viewport="' . esc_attr($view) . '" class="button button-secondary button-small gppro-button-right gppro-freeform-preview">' . __('Preview CSS', 'gp-pro-freeform-style') . '</span>'; // Close up the field wrapper. $input .= '</div>'; $input .= '</div>'; // Send it back. return $input; }
/** * create input field for CSS export * * @return */ static function export_css_input($field, $item) { // bail if items missing if (!$field || !$item) { return; } // first check for the data $saved = get_option('gppro-settings'); // display message without saved options if (empty($saved)) { $text = __('No data has been saved. Please save your settings before attempting to export.', 'gppro-export-css'); return '<div class="gppro-input gppro-description-input"><p class="description">' . esc_attr($text) . '</p></div>'; } // get my values $id = GP_Pro_Helper::get_field_id($field); $name = GP_Pro_Helper::get_field_name($field); $button = !empty($item['button']) ? esc_attr($item['button']) : __('Export File', 'gppro-export-css'); // get CSS file for link $file = Genesis_Palette_Pro::filebase(); // create export URL with nonce $expnonce = wp_create_nonce('gppro_css_export_nonce'); // set the empty $input = ''; // begin markup $input .= '<div class="gppro-input gppro-css-export-input gppro-setting-input">'; // handle label with optional CSS file link $input .= '<div class="gppro-input-item gppro-input-wrap"><p class="description">'; $input .= esc_attr($item['label']); // handle browser link if (file_exists($file['dir']) && !empty($file['url'])) { $input .= '<a class="gppro-css-export-view" href="' . esc_url($file['url']) . '" title="' . __('View in browser', 'gppro-export-css') . '" target="_blank">'; $input .= '<i class="dashicons dashicons-admin-site"></i>'; $input .= '</a>'; } $input .= '</p></div>'; // display button $input .= '<div class="gppro-input-item gppro-input-label choice-label">'; $input .= '<span class="gppro-settings-button">'; $input .= '<a name="' . esc_attr($name) . '" id="' . sanitize_html_class($id) . '" href="' . menu_page_url('genesis-palette-pro', 0) . '&gppro-css-export=go&_wpnonce=' . $expnonce . '" class="button-primary button-small ' . esc_attr($field) . '">' . $button . '</a>'; $input .= '</span>'; $input .= '</div>'; // close markup $input .= '</div>'; // send it back return $input; }