Skip to content

Commit

Permalink
third party support
Browse files Browse the repository at this point in the history
  • Loading branch information
michelve committed Aug 9, 2018
1 parent 1bd62f9 commit 16ba24f
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 7 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

/* * ********************************* */
/* * * WP eStore Plugin Integration ** */
/* * ********************************* */

add_filter('eStore_notification_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Standard sale notification email
add_filter('eStore_squeeze_form_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Squeeze form email
function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items) {
Expand Down
10 changes: 9 additions & 1 deletion software-license-manager/admin/slm-lic-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function wp_lic_mgr_general_settings() {
'enable_debug' => isset($_POST['enable_debug']) ? '1':'',
'slm_woo' => isset($_POST['slm_woo']) ? '1':'',
'slm_subscriptio' => isset($_POST['slm_subscriptio']) ? '1':'',
'slm_wpestores' => isset($_POST['slm_wpestores']) ? '1':'',
);
update_option('slm_plugin_options', $options);

Expand Down Expand Up @@ -138,8 +139,15 @@ function wp_lic_mgr_general_settings() {
<input name="slm_subscriptio" type="checkbox"<?php if ($options['slm_subscriptio'] != '') echo ' checked="checked"'; ?> value="1"/>

<br />Subscriptio is a WooCommerce extension that allows you to sell subscriptions. Subscriptio adds recurring payments capability to WooCommerce so you can sell products like magazine subscriptions, online memberships, e-learning packages and any other tangible or intangible products. <a href="https://codecanyon.net/item/subscriptio-woocommerce-subscriptions/8754068">Learn More</a></td>
</tr>
</tr
<tr valign="top">
<th scope="row">WP eStores Support</th>
<td>
<input name="slm_wpestores" type="checkbox"<?php if ($options['slm_wpestores'] != '') echo ' checked="checked"'; ?> value="1"/> <br>
WordPress eStore Plugin – Complete Solution to Sell Digital Products from Your WordPress Blog Securely

</td>
</tr>



Expand Down
160 changes: 159 additions & 1 deletion software-license-manager/includes/slm-meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,162 @@ function save_variation_fields( $variation_id, $i) {
$text_field = stripslashes( $_POST['amount_of_licenses_devices'][$i] );
update_post_meta( $variation_id, 'amount_of_licenses_devices', esc_attr( $text_field ) );

}
}






























// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'License', 'woocommerce' ),
'target' => 'my_custom_product_data',
'class' => array( 'show_if_simple', 'show_if_variable' ),
);
return $product_data_tabs;
}





// functions you can call to output text boxes, select boxes, etc.
add_action('woocommerce_product_data_panels', 'woocom_custom_product_data_fields');

function woocom_custom_product_data_fields() {
global $post;

// Note the 'id' attribute needs to match the 'target' parameter set above
?> <div id = 'my_custom_product_data'
class = 'panel woocommerce_options_panel' > <?php
?> <div class = 'options_group' > <?php
// Text Field
woocommerce_wp_text_input(
array(
'id' => '_text_field',
'label' => __( 'Custom Text Field', 'woocommerce' ),
'wrapper_class' => 'show_if_simple', //show_if_simple or show_if_variable
'placeholder' => 'Custom text field',
'desc_tip' => 'true',
'description' => __( 'Enter the custom value here.', 'woocommerce' )
)
);

// Number Field
woocommerce_wp_text_input(
array(
'id' => '_number_field',
'label' => __( 'Custom Number Field', 'woocommerce' ),
'placeholder' => '',
'description' => __( 'Enter the custom value here.', 'woocommerce' ),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '15'
)
)
);

// Checkbox
woocommerce_wp_checkbox(
array(
'id' => '_checkbox',
'label' => __('Custom Checkbox Field', 'woocommerce' ),
'description' => __( 'Check me!', 'woocommerce' )
)
);

// Select
woocommerce_wp_select(
array(
'id' => '_select',
'label' => __( 'Custom Select Field', 'woocommerce' ),
'options' => array(
'one' => __( 'Custom Option 1', 'woocommerce' ),
'two' => __( 'Custom Option 2', 'woocommerce' ),
'three' => __( 'Custom Option 3', 'woocommerce' )
)
)
);

// Textarea
woocommerce_wp_textarea_input(
array(
'id' => '_textarea',
'label' => __( 'Custom Textarea', 'woocommerce' ),
'placeholder' => '',
'description' => __( 'Enter the value here.', 'woocommerce' )
)
);
?> </div>

</div><?php
}

/** Hook callback function to save custom fields information */
function woocom_save_proddata_custom_fields($post_id) {
// Save Text Field
$text_field = $_POST['_text_field'];
if (!empty($text_field)) {
update_post_meta($post_id, '_text_field', esc_attr($text_field));
}

// Save Number Field
$number_field = $_POST['_number_field'];
if (!empty($number_field)) {
update_post_meta($post_id, '_number_field', esc_attr($number_field));
}
// Save Textarea
$textarea = $_POST['_textarea'];
if (!empty($textarea)) {
update_post_meta($post_id, '_textarea', esc_html($textarea));
}

// Save Select
$select = $_POST['_select'];
if (!empty($select)) {
update_post_meta($post_id, '_select', esc_attr($select));
}

// Save Checkbox
$checkbox = isset($_POST['_checkbox']) ? 'yes' : 'no';
update_post_meta($post_id, '_checkbox', $checkbox);

// Save Hidden field
$hidden = $_POST['_hidden_field'];
if (!empty($hidden)) {
update_post_meta($post_id, '_hidden_field', esc_attr($hidden));
}
}

add_action( 'woocommerce_process_product_meta_simple', 'woocom_save_proddata_custom_fields' );

// You can uncomment the following line if you wish to use those fields for "Variable Product Type"
//add_action( 'woocommerce_process_product_meta_variable', 'woocom_save_proddata_custom_fields' );
17 changes: 12 additions & 5 deletions software-license-manager/includes/slm_plugin_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,31 @@ function deactivate_software_license_manager() {
include_once( SLM_LIB .'slm-init-time-tasks.php');
include_once( SLM_LIB .'slm-api-utility.php');
include_once( SLM_LIB .'slm-api-listener.php');
include_once( SLM_LIB .'slm-third-party-integration.php');

// Front end-menu
// TODO check for optional plugins

// Third Party Support
if (null !== SLM_Helper_Class::slm_get_option('slm_woo') && SLM_Helper_Class::slm_get_option('slm_woo') == 1) {
include_once( SLM_PUBLIC . 'slm-add-menu-frontend.php');

// WordPress Plugin :: wc-software-license-manager
include_once( SLM_ADMIN . 'includes/woocommerce/wc-software-license-manager.php');

// support for meta boxes (variations only, this can be applied to single prodicts as well)
include_once( SLM_LIB . 'slm-meta-boxes.php');
}

if (null !== SLM_Helper_Class::slm_get_option('slm_subscriptio') && SLM_Helper_Class::slm_get_option('slm_subscriptio') == 1) {
// Subscriptio PLugin Intergration
// TODO - check for plugin exist
include_once( SLM_LIB . 'slm-subscriptio.php');
include_once( SLM_ADMIN . 'includes/subscriptio/slm-subscriptio.php');
}

if (null !== SLM_Helper_Class::slm_get_option('slm_wpestores') && SLM_Helper_Class::slm_get_option('slm_wpestores') == 1) {
// wpestores PLugin Intergration
include_once( SLM_ADMIN . 'includes/wpestores/slm-wpestores.php');
}

// support for meta boxes (variations only, this can be applied to single prodicts as well)
include_once( SLM_LIB . 'slm-meta-boxes.php');

//Include admin side only files
if (is_admin()) {
Expand All @@ -112,6 +117,7 @@ function slm_init_handler() {
$init_task = new SLM_Init_Time_Tasks();
$api_listener = new SLM_API_Listener();
}

//Do plugins loaded time tasks
function slm_plugins_loaded_handler() {
//Runs when plugins_loaded action gets fired
Expand All @@ -123,6 +129,7 @@ function slm_plugins_loaded_handler() {
}
}
}

//TODO - need to move this to an ajax handler file
function slm_del_reg_dom() {
global $wpdb;
Expand Down

0 comments on commit 16ba24f

Please sign in to comment.