function mbpro_update_button_icon_width($id, $icon_width) { global $wpdb; $wpdb->query($wpdb->prepare("UPDATE " . mbpro_get_buttons_table_name() . " SET icon_width = %s WHERE id = %d", $icon_width, $id)); }
$icon_url = stripslashes($_POST[$maxbutton_icon_url_key]); $icon_width = ''; if (isset($icon_url) && $icon_url != '') { $icon_width = mbpro_get_image_width_from_url($icon_url); } $data = array('name' => $_POST[$maxbutton_name_key] != '' ? stripslashes($_POST[$maxbutton_name_key]) : __('Unnamed Button', 'maxbuttons-pro'), 'description' => stripslashes($_POST[$maxbutton_description_key]), 'url' => stripslashes($_POST[$maxbutton_url_key]), 'new_window' => isset($_POST[$maxbutton_new_window_key]) ? $wpdb->escape($_POST[$maxbutton_new_window_key]) : '', 'nofollow' => isset($_POST[$maxbutton_nofollow_key]) ? $wpdb->escape($_POST[$maxbutton_nofollow_key]) : '', 'width' => $_POST[$maxbutton_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_width_key]) . 'px' : $maxbutton_width_default, 'height' => $_POST[$maxbutton_height_key] != '' ? $wpdb->escape($_POST[$maxbutton_height_key]) . 'px' : $maxbutton_height_default, 'icon_url' => stripslashes($_POST[$maxbutton_icon_url_key]), 'icon_position' => $_POST[$maxbutton_icon_position_key] != '' ? $wpdb->escape($_POST[$maxbutton_icon_position_key]) : $maxbutton_icon_position_default, 'icon_padding_top' => $_POST[$maxbutton_icon_padding_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_icon_padding_top_key]) . 'px' : $maxbutton_icon_padding_top_default, 'icon_padding_bottom' => $_POST[$maxbutton_icon_padding_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_icon_padding_bottom_key]) . 'px' : $maxbutton_icon_padding_bottom_default, 'icon_padding_left' => $_POST[$maxbutton_icon_padding_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_icon_padding_left_key]) . 'px' : $maxbutton_icon_padding_left_default, 'icon_padding_right' => $_POST[$maxbutton_icon_padding_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_icon_padding_right_key]) . 'px' : $maxbutton_icon_padding_right_default, 'icon_width' => $icon_width, 'icon_alt' => stripslashes($_POST[$maxbutton_icon_alt_key]), 'text' => stripslashes($_POST[$maxbutton_text_key]), 'text_font_family' => $_POST[$maxbutton_text_font_family_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_family_key]) : $maxbutton_text_font_family_default, 'text_font_size' => $_POST[$maxbutton_text_font_size_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_size_key]) : $maxbutton_text_font_size_default, 'text_font_style' => $_POST[$maxbutton_text_font_style_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_style_key]) : $maxbutton_text_font_style_default, 'text_font_weight' => $_POST[$maxbutton_text_font_weight_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_weight_key]) : $maxbutton_text_font_weight_default, 'text_align' => $_POST[$maxbutton_text_align_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_align_key]) : $maxbutton_text_align_default, 'text_padding_top' => $_POST[$maxbutton_text_padding_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_top_key]) . 'px' : $maxbutton_text_padding_top_default, 'text_padding_bottom' => $_POST[$maxbutton_text_padding_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_bottom_key]) . 'px' : $maxbutton_text_padding_bottom_default, 'text_padding_left' => $_POST[$maxbutton_text_padding_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_left_key]) . 'px' : $maxbutton_text_padding_left_default, 'text_padding_right' => $_POST[$maxbutton_text_padding_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_right_key]) . 'px' : $maxbutton_text_padding_right_default, 'text2' => stripslashes($_POST[$maxbutton_text2_key]), 'text2_font_family' => $_POST[$maxbutton_text2_font_family_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_font_family_key]) : $maxbutton_text2_font_family_default, 'text2_font_size' => $_POST[$maxbutton_text2_font_size_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_font_size_key]) : $maxbutton_text2_font_size_default, 'text2_font_style' => $_POST[$maxbutton_text2_font_style_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_font_style_key]) : $maxbutton_text2_font_style_default, 'text2_font_weight' => $_POST[$maxbutton_text2_font_weight_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_font_weight_key]) : $maxbutton_text2_font_weight_default, 'text2_align' => $_POST[$maxbutton_text2_align_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_align_key]) : $maxbutton_text2_align_default, 'text2_padding_top' => $_POST[$maxbutton_text2_padding_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_padding_top_key]) . 'px' : $maxbutton_text2_padding_top_default, 'text2_padding_bottom' => $_POST[$maxbutton_text2_padding_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_padding_bottom_key]) . 'px' : $maxbutton_text2_padding_bottom_default, 'text2_padding_left' => $_POST[$maxbutton_text2_padding_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_padding_left_key]) . 'px' : $maxbutton_text2_padding_left_default, 'text2_padding_right' => $_POST[$maxbutton_text2_padding_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_text2_padding_right_key]) . 'px' : $maxbutton_text2_padding_right_default, 'text_color' => $_POST[$maxbutton_text_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_color_key]) : $maxbutton_text_color_default, 'text_color_hover' => $_POST[$maxbutton_text_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_color_hover_key]) : $maxbutton_text_color_hover_default, 'text_shadow_offset_left' => $_POST[$maxbutton_text_shadow_offset_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_offset_left_key]) . 'px' : $maxbutton_text_shadow_offset_left_default, 'text_shadow_offset_top' => $_POST[$maxbutton_text_shadow_offset_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_offset_top_key]) . 'px' : $maxbutton_text_shadow_offset_top_default, 'text_shadow_width' => $_POST[$maxbutton_text_shadow_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_width_key]) . 'px' : $maxbutton_text_shadow_width_default, 'text_shadow_color' => $_POST[$maxbutton_text_shadow_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_color_key]) : $maxbutton_text_shadow_color_default, 'text_shadow_color_hover' => $_POST[$maxbutton_text_shadow_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_color_hover_key]) : $maxbutton_text_shadow_color_hover_default, 'border_radius_top_left' => $_POST[$maxbutton_border_radius_top_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_top_left_key]) . 'px' : $maxbutton_border_radius_top_left_default, 'border_radius_top_right' => $_POST[$maxbutton_border_radius_top_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_top_right_key]) . 'px' : $maxbutton_border_radius_top_right_default, 'border_radius_bottom_left' => $_POST[$maxbutton_border_radius_bottom_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_bottom_left_key]) . 'px' : $maxbutton_border_radius_bottom_left_default, 'border_radius_bottom_right' => $_POST[$maxbutton_border_radius_bottom_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_bottom_right_key]) . 'px' : $maxbutton_border_radius_bottom_right_default, 'border_style' => $_POST[$maxbutton_border_style_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_style_key]) : $maxbutton_border_style_default, 'border_width' => $_POST[$maxbutton_border_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_width_key]) . 'px' : $maxbutton_border_width_default, 'border_color' => $_POST[$maxbutton_border_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_color_key]) : $maxbutton_border_color_default, 'border_color_hover' => $_POST[$maxbutton_border_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_color_hover_key]) : $maxbutton_border_color_hover_default, 'box_shadow_offset_left' => $_POST[$maxbutton_box_shadow_offset_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_offset_left_key]) . 'px' : $maxbutton_box_shadow_offset_left_default, 'box_shadow_offset_top' => $_POST[$maxbutton_box_shadow_offset_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_offset_top_key]) . 'px' : $maxbutton_box_shadow_offset_top_default, 'box_shadow_width' => $_POST[$maxbutton_box_shadow_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_width_key]) . 'px' : $maxbutton_box_shadow_width_default, 'box_shadow_color' => $_POST[$maxbutton_box_shadow_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_color_key]) : $maxbutton_box_shadow_color_default, 'box_shadow_color_hover' => $_POST[$maxbutton_box_shadow_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_color_hover_key]) : $maxbutton_box_shadow_color_hover_default, 'gradient_start_color' => $_POST[$maxbutton_gradient_start_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_color_key]) : $maxbutton_gradient_start_color_default, 'gradient_start_color_hover' => $_POST[$maxbutton_gradient_start_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_color_hover_key]) : $maxbutton_gradient_start_color_hover_default, 'gradient_end_color' => $_POST[$maxbutton_gradient_end_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_color_key]) : $maxbutton_gradient_end_color_default, 'gradient_end_color_hover' => $_POST[$maxbutton_gradient_end_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_color_hover_key]) : $maxbutton_gradient_end_color_hover_default, 'gradient_stop' => $_POST[$maxbutton_gradient_stop_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_stop_key]) : $maxbutton_gradient_stop_default, 'gradient_start_opacity' => $_POST[$maxbutton_gradient_start_opacity_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_opacity_key]) : $maxbutton_gradient_start_opacity_default, 'gradient_end_opacity' => $_POST[$maxbutton_gradient_end_opacity_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_opacity_key]) : $maxbutton_gradient_end_opacity_default, 'gradient_start_opacity_hover' => $_POST[$maxbutton_gradient_start_opacity_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_opacity_hover_key]) : $maxbutton_gradient_start_opacity_hover_default, 'gradient_end_opacity_hover' => $_POST[$maxbutton_gradient_end_opacity_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_opacity_hover_key]) : $maxbutton_gradient_end_opacity_hover_default, 'container_enabled' => $_POST[$maxbutton_container_enabled_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_enabled_key]) : $maxbutton_container_enabled_default, 'container_width' => $_POST[$maxbutton_container_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_width_key]) . 'px' : '', 'container_margin_top' => $_POST[$maxbutton_container_margin_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_top_key]) . 'px' : '', 'container_margin_right' => $_POST[$maxbutton_container_margin_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_right_key]) . 'px' : '', 'container_margin_bottom' => $_POST[$maxbutton_container_margin_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_bottom_key]) . 'px' : '', 'container_margin_left' => $_POST[$maxbutton_container_margin_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_left_key]) . 'px' : '', 'container_alignment' => $_POST[$maxbutton_container_alignment_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_alignment_key]) : '', 'container_center_div_wrap_enabled' => isset($_POST[$maxbutton_container_center_div_wrap_enabled_key]) ? $wpdb->escape($_POST[$maxbutton_container_center_div_wrap_enabled_key]) : '', 'external_css' => isset($_POST[$maxbutton_external_css_key]) ? $wpdb->escape($_POST[$maxbutton_external_css_key]) : '', 'important_css' => isset($_POST[$maxbutton_important_css_key]) ? $wpdb->escape($_POST[$maxbutton_important_css_key]) : ''); if ($_GET['id'] == '') { // This is a new button $wpdb->insert(mbpro_get_buttons_table_name(), $data); $button_id = $wpdb->insert_id; } else { // Updating an existing button $where = array('id' => $_GET['id']); $data_format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'); $where_format = array('%d'); $wpdb->update(mbpro_get_buttons_table_name(), $data, $where, $data_format, $where_format); $button_id = $_GET['id']; } $redirect = true; } ?> <script type="text/javascript"> <?php if ($redirect == true) { ?> window.location = "<?php echo admin_url(); ?>
<?php if (isset($_GET['id']) && $_GET['id'] != '') { $button = mbpro_get_button($_GET['id']); $data = array('name' => $button->name, 'description' => $button->description, 'url' => $button->url, 'new_window' => $button->new_window, 'nofollow' => $button->nofollow, 'width' => $button->width, 'height' => $button->height, 'icon_url' => $button->icon_url, 'icon_position' => $button->icon_position, 'icon_padding_top' => $button->icon_padding_top, 'icon_padding_bottom' => $button->icon_padding_bottom, 'icon_padding_left' => $button->icon_padding_left, 'icon_padding_right' => $button->icon_padding_right, 'icon_alt' => $button->icon_alt, 'text' => $button->text, 'text_font_family' => $button->text_font_family, 'text_font_size' => $button->text_font_size, 'text_font_style' => $button->text_font_style, 'text_font_weight' => $button->text_font_weight, 'text_align' => $button->text_align, 'text_padding_top' => $button->text_padding_top, 'text_padding_bottom' => $button->text_padding_bottom, 'text_padding_left' => $button->text_padding_left, 'text_padding_right' => $button->text_padding_right, 'text2' => $button->text2, 'text2_font_family' => $button->text2_font_family, 'text2_font_size' => $button->text2_font_size, 'text2_font_style' => $button->text2_font_style, 'text2_font_weight' => $button->text2_font_weight, 'text2_align' => $button->text2_align, 'text2_padding_top' => $button->text2_padding_top, 'text2_padding_bottom' => $button->text2_padding_bottom, 'text2_padding_left' => $button->text2_padding_left, 'text2_padding_right' => $button->text2_padding_right, 'text_color' => $button->text_color, 'text_color_hover' => $button->text_color_hover, 'text_shadow_offset_left' => $button->text_shadow_offset_left, 'text_shadow_offset_top' => $button->text_shadow_offset_top, 'text_shadow_width' => $button->text_shadow_width, 'text_shadow_color' => $button->text_shadow_color, 'text_shadow_color_hover' => $button->text_shadow_color_hover, 'border_radius_top_left' => $button->border_radius_top_left, 'border_radius_top_right' => $button->border_radius_top_right, 'border_radius_bottom_left' => $button->border_radius_bottom_left, 'border_radius_bottom_right' => $button->border_radius_bottom_right, 'border_style' => $button->border_style, 'border_width' => $button->border_width, 'border_color' => $button->border_color, 'border_color_hover' => $button->border_color_hover, 'box_shadow_offset_left' => $button->box_shadow_offset_left, 'box_shadow_offset_top' => $button->box_shadow_offset_top, 'box_shadow_width' => $button->box_shadow_width, 'box_shadow_color' => $button->box_shadow_color, 'box_shadow_color_hover' => $button->box_shadow_color_hover, 'gradient_start_color' => $button->gradient_start_color, 'gradient_start_color_hover' => $button->gradient_start_color_hover, 'gradient_end_color' => $button->gradient_end_color, 'gradient_start_opacity' => $button->gradient_start_opacity, 'gradient_end_opacity' => $button->gradient_end_opacity, 'gradient_start_opacity_hover' => $button->gradient_start_opacity_hover, 'gradient_end_opacity_hover' => $button->gradient_end_opacity_hover, 'gradient_end_color_hover' => $button->gradient_end_color_hover, 'gradient_stop' => $button->gradient_stop, 'container_enabled' => $button->container_enabled, 'container_width' => $button->container_width, 'container_margin_top' => $button->container_margin_top, 'container_margin_right' => $button->container_margin_right, 'container_margin_bottom' => $button->container_margin_bottom, 'container_margin_left' => $button->container_margin_left, 'container_alignment' => $button->container_alignment, 'container_center_div_wrap_enabled' => $button->container_center_div_wrap_enabled, 'status' => $button->status); global $wpdb; $wpdb->insert(mbpro_get_buttons_table_name(), $data); $button_id = $wpdb->insert_id; } ?> <script type="text/javascript"> <?php if (isset($_GET['id']) && $_GET['id'] != '') { ?> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=button&id=<?php echo $button_id; ?> "; <?php } else { ?> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=list";
$pack_name = stripslashes($_POST['pack_name']); $pack_description = stripslashes($_POST['pack_description']); $pack_author = stripslashes($_POST['pack_author']); $pack_author_url = stripslashes($_POST['pack_author_url']); // Build the WHERE clause to get the buttons $where = ''; foreach ($_POST as $key => $value) { if (mbpro_starts_with($key, 'maxbutton_')) { $where .= 'id = ' . $value . ' OR '; } } if ($where != '') { // Remove the last 4 chars, which is the trailing ' OR ' $where = substr($where, 0, -4); // Get the buttons $export_buttons = $wpdb->get_results("SELECT * FROM " . mbpro_get_buttons_table_name() . " WHERE " . $where); } // Get the pack name by replacing spaces with dashes and stripping out any // special chars by only accepting letters, numbers, underscores, and dashes $pack_name = str_replace(' ', '-', $pack_name); $pack_name = preg_replace('/[^a-zA-Z0-9_-]/s', '', $pack_name); $pack_name = strtolower($pack_name); // Create the pack folder in the exports folder $pack_folder = MAXBUTTONS_PRO_EXPORTS_DIR . '/' . $pack_name . '/'; mkdir($pack_folder); // The root node $xml = '<maxbuttons>'; // Pack element and attributes $xml .= '<pack '; $xml .= 'name="' . stripslashes($_POST['pack_name']) . '" '; $xml .= 'description="' . $pack_description . '" ';