<commit_before><?php
/**
 * BadgeOS Shortcodes WP Editor Class
 *
 * @package BadgeOS
 * @subpackage Classes
 * @author LearningTimes, LLC
 * @license http://www.gnu.org/licenses/agpl.txt GNU AGPL v3.0
 * @link https://credly.com
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class BadgeOS_Editor_Shortcodes {

	public function __construct() {
		$this->directory_path = plugin_dir_path( dirname( __FILE__ ) );
		$this->directory_url  = plugin_dir_url( dirname( __FILE__ ) );
		$this->shortcodes     = badgeos_get_shortcodes();

		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 99 );
		add_action( 'media_buttons', array( $this, 'render_button'), 20 );
		add_action( 'admin_footer',  array( $this, 'render_modal' ) );

	}

	/**
	 * Enqueue and localize relevant admin_scripts.
	 *
	 * @since  1.4.0
	 */
	public function admin_scripts() {
		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
		$min = '';
		wp_enqueue_script( 'badgeos-select2', $this->directory_url . "js/select2/select2$min.js", array( 'jquery' ), '', true );
		wp_enqueue_script( 'badgeos-shortcodes-embed', $this->directory_url . "js/badgeos-shortcode-embed$min.js", array( 'jquery', 'badgeos-select2' ), '', true );
		wp_localize_script( 'badgeos-shortcodes-embed', 'badgeos_shortcode_embed_messages', $this->get_localized_text() );
		wp_enqueue_style( 'badgeos-select2-css', $this->directory_url . 'js/select2/select2.css' );
	}

	/**
	 * Get localized JS text.
	 *
	 * @since 1.4.0
	 *
	 * @return array Array of translated text
	 */
	public function get_localized_text() {
		return array(
			'id_placeholder'          => __( 'Select a Post', 'badgeos' ),
			'id_multiple_placeholder' => __( 'Select Post(s)', 'badgeos' ),
			'user_placeholder'        => __( 'Select a user', 'badgeos' ),
			'post_type_placeholder'   => __( 'Default: All', 'badgeos' ),
		);
	}

	/**
	 * Render shortcode modal insert button.
	 *
	 * @since 1.4.0
	 */
	public function render_button() {
		echo '<a id="insert_badgeos_shortcodes" href="#TB_inline?width=660&height=800&inlineId=select_badgeos_shortcode" class="thickbox button badgeos_media_link">' . __( 'Add BadgeOS Shortcode', 'badgeos' ) . '</a>';
	}

	/**
	 * Render shortcode modal content.
	 *
	 * @since 1.4.0
	 */
	public function render_modal() { ?>
		<div id="select_badgeos_shortcode" style="display:none;">
			<div class="wrap">
				<h3><?php _e( 'Insert a BadgeOS shortcode', 'badgeos' ); ?></h3>
				<p><?php printf( __( 'See the %s page for more information', 'badgeos' ), '<a target="_blank" href="' . admin_url( 'admin.php?page=badgeos_sub_help_support' ) . '">' . __( 'Help/Support', 'badgeos' ) . '</a>' ); ?></p>
				<div class="alignleft">
					<select id="select_shortcode"><?php echo $this->get_shortcode_selector(); ?></select>
				</div>
				<div class="alignright">
					<a id="badgeos_insert" class="button-primary" href="#" style="color:#fff;"><?php esc_attr_e( 'Insert Shortcode', 'badgeos' ); ?></a>
					<a id="badgeos_cancel" class="button-secondary" href="#"><?php esc_attr_e( 'Cancel', 'badgeos' ); ?></a>
				</div>
				<div id="shortcode_options" class="alignleft clear">
					<?php echo $this->get_shortcode_sections(); ?>
				</div><commit_msg>add our data attribute<commit_after><?php
/**
 * BadgeOS Shortcodes WP Editor Class
 *
 * @package BadgeOS
 * @subpackage Classes
 * @author LearningTimes, LLC
 * @license http://www.gnu.org/licenses/agpl.txt GNU AGPL v3.0
 * @link https://credly.com
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class BadgeOS_Editor_Shortcodes {

	public function __construct() {
		$this->directory_path = plugin_dir_path( dirname( __FILE__ ) );
		$this->directory_url  = plugin_dir_url( dirname( __FILE__ ) );
		$this->shortcodes     = badgeos_get_shortcodes();

		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 99 );
		add_action( 'media_buttons', array( $this, 'render_button'), 20 );
		add_action( 'admin_footer',  array( $this, 'render_modal' ) );

	}

	/**
	 * Enqueue and localize relevant admin_scripts.
	 *
	 * @since  1.4.0
	 */
	public function admin_scripts() {
		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
		$min = '';
		wp_enqueue_script( 'badgeos-select2', $this->directory_url . "js/select2/select2$min.js", array( 'jquery' ), '', true );
		wp_enqueue_script( 'badgeos-shortcodes-embed', $this->directory_url . "js/badgeos-shortcode-embed$min.js", array( 'jquery', 'badgeos-select2' ), '', true );
		wp_localize_script( 'badgeos-shortcodes-embed', 'badgeos_shortcode_embed_messages', $this->get_localized_text() );
		wp_enqueue_style( 'badgeos-select2-css', $this->directory_url . 'js/select2/select2.css' );
	}

	/**
	 * Get localized JS text.
	 *
	 * @since 1.4.0
	 *
	 * @return array Array of translated text
	 */
	public function get_localized_text() {
		return array(
			'id_placeholder'          => __( 'Select a Post', 'badgeos' ),
			'id_multiple_placeholder' => __( 'Select Post(s)', 'badgeos' ),
			'user_placeholder'        => __( 'Select a user', 'badgeos' ),
			'post_type_placeholder'   => __( 'Default: All', 'badgeos' ),
		);
	}

	/**
	 * Render shortcode modal insert button.
	 *
	 * @since 1.4.0
	 */
	public function render_button() {
		echo '<a id="insert_badgeos_shortcodes" href="#TB_inline?width=660&height=800&inlineId=select_badgeos_shortcode" class="thickbox button badgeos_media_link" data-width="800">' . __( 'Add BadgeOS Shortcode', 'badgeos' ) . '</a>';
	}

	/**
	 * Render shortcode modal content.
	 *
	 * @since 1.4.0
	 */
	public function render_modal() { ?>
		<div id="select_badgeos_shortcode" style="display:none;">
			<div class="wrap">
				<h3><?php _e( 'Insert a BadgeOS shortcode', 'badgeos' ); ?></h3>
				<p><?php printf( __( 'See the %s page for more information', 'badgeos' ), '<a target="_blank" href="' . admin_url( 'admin.php?page=badgeos_sub_help_support' ) . '">' . __( 'Help/Support', 'badgeos' ) . '</a>' ); ?></p>
				<div class="alignleft">
					<select id="select_shortcode"><?php echo $this->get_shortcode_selector(); ?></select>
				</div>
				<div class="alignright">
					<a id="badgeos_insert" class="button-primary" href="#" style="color:#fff;"><?php esc_attr_e( 'Insert Shortcode', 'badgeos' ); ?></a>
					<a id="badgeos_cancel" class="button-secondary" href="#"><?php esc_attr_e( 'Cancel', 'badgeos' ); ?></a>
				</div>
				<div id="shortcode_options" class="alignleft clear">
					<?php echo $this->get_shortcode_sections(); ?>
				</div>
{'fraction_non_alphanumeric': 0.18128834355828222, 'fraction_numerical': 0.01058282208588957, 'mean_word_length': 4.250402576489533, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 87, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6530726', 'n_tokens_mistral': 2503, 'n_tokens_neox': 2308, 'n_words': 471}