<commit_before><?php
/* 
Plugin Name: SMSAPI plugin extensions
Description: Custom extensions to the Newsletter SMS - SMSAPI 
plugin, like e.g. counting characters.
Version:     1.0.0-rc1
Author:	     Ayanami <<EMAIL>>
Depends:     Newsletter SMS - SMSAPI
License:     Artistic License 2.0

Copyright (c) 2016 Ayanami <<EMAIL>>
Licensed under the Artistic License 2.0
https://opensource.org/licenses/Artistic-2.0
*/
defined('ABSPATH') or die('No direct access please.');
define('SMSAPI_ADDONS_PATH', plugins_url('smsapi-addons'));
define('SMSAPI_PLUGIN_PATH', plugins_url('newsletter-sms-smsapi'));

require_once SMSAPI_PLUGIN_PATH . 'gateway.php';
require_once SMSAPI_PLUGIN_PATH . 'routing.php';

// TODO activate hook to activate newsletter-sms-smsapi along with this plugin
// TODO newsletter-sms-smsapi deactivate hook, to also deactivate this plugin

function modify_smsapi_menu() {
	$menu = remove_submenu_page('smsapi-settings','smsapi-send-sms');
	if($menu !== false) {
		add_submenu_page('smsapi-settings',
			'SMSAPI - sendsms',
			__('Send SMS', 'smsapi'),
			'manage_options', 
			'smsapi-revised-sms',
			'smsapi_addons_gateway_routing'
		);	
	}
}

function action_addons_gateway() {
	action_gateway();
	wp_enqueue_style('smsapi-addons-lettercount-css',SMSAPI_ADDONS_PATH.'/charcounter-style.css');
	wp_enqueue_script('smsapi-addons-lettercount-js',SMSAPI_ADDONS_PATH.'/lettercount.js');
}

function smsapi_addons_gateway_routing() {
    $recipientsNumbers = session_get_once('gateway_recipients', array());

    try {
        action_addons_gateway($recipientsNumbers);
    } catch (\SMSApi\Exception\SmsapiException $error) {
        handle_smsapi_exception($error);<commit_msg>added editor-accessible (publish_page capability) send-sms menu page, so clients may have the role lower than admin, to prevent them from accessing and modifying smsapi settings, and in the future allow counting amount of messages sent.<commit_after><?php
/* 
Plugin Name: SMSAPI plugin extensions
Description: Custom extensions to the Newsletter SMS - SMSAPI 
plugin, like e.g. counting characters.
Version:     1.0.0-rc2
Author:	     Ayanami <<EMAIL>>
Depends:     Newsletter SMS - SMSAPI
License:     Artistic License 2.0

Copyright (c) 2016 Ayanami <<EMAIL>>
Licensed under the Artistic License 2.0
https://opensource.org/licenses/Artistic-2.0
*/
defined('ABSPATH') or die('No direct access please.');
define('SMSAPI_ADDONS_PATH', plugins_url('smsapi-addons'));
define('SMSAPI_PLUGIN_PATH', plugins_url('newsletter-sms-smsapi'));

require_once SMSAPI_PLUGIN_PATH . 'gateway.php';
require_once SMSAPI_PLUGIN_PATH . 'routing.php';

// TODO activate hook to activate newsletter-sms-smsapi along with this plugin
// TODO newsletter-sms-smsapi deactivate hook, to also deactivate this plugin

function modify_smsapi_menu() {
	$menu = remove_submenu_page('smsapi-settings','smsapi-send-sms');
	if($menu !== false) {
		add_submenu_page('smsapi-settings',
			'SMSAPI - sendsms',
			__('Send SMS', 'smsapi'),
			'publish_pages', 
			'smsapi-revised-sms',
			'smsapi_addons_gateway_routing'
		);	
	} else {
		add_menu_page(__('Send SMS', 'smsapi'), 'SEND SMS',
			'publish_pages',
			'send-sms-editor',
			'smsapi_addons_gateway_routing'
		);
	}
}

function action_addons_gateway() {
	action_gateway();
	wp_enqueue_style('smsapi-addons-lettercount-css',SMSAPI_ADDONS_PATH.'/charcounter-style.css');
	wp_enqueue_script('smsapi-addons-lettercount-js',SMSAPI_ADDONS_PATH.'/lettercount.js');
}

function smsapi_addons_gateway_routing() {
    $recipientsNumbers = session_get_once('gateway_recipients', array());

    try {
        action_addons_gateway($recipientsNumbers);
    } catch (\SMSApi\Exception\SmsapiException $error) {
        handle_smsapi_exception($error);
{'fraction_non_alphanumeric': 0.1241342567927544, 'fraction_numerical': 0.007458710708577517, 'mean_word_length': 5.175986842105263, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1187134', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1295, 'n_words': 262}