Пример #1
0
        /**
         * Display chatbox
         *
         * @access public
         * @return void
         */
        function display_chatbox()
        {
            // Get plugin options
            $plugin_opts = cx_get_jquery_plug_opts();
            ?>

		<div id="CX_chatbox"></div>

		<script type="text/javascript">
		(function ($) {

			$(document).ready(function () {
				
				var el = $('#CX_chatbox');

				/**
				 * Initialize Screets Chat plugin
				 */
				el.cx({
					<?php 
            cx_print_custom_opts($plugin_opts);
            ?>
				});

			});
			
		} (window.jQuery || window.Zepto));

		</script>

	<?php 
        }
Пример #2
0
/**
 * Print custom options
 */
function cx_print_custom_opts($opts, $property = null)
{
    $total_opts = count($opts);
    if ($property) {
        echo $property . ": {\n\t\t\t\t";
    }
    $i = 1;
    foreach ($opts as $k => $v) {
        $comma = $i < $total_opts ? ",\n\t\t\t" : "\n";
        //
        // Print single line option
        //
        if (!is_array($v) or !empty($v['_FUNC_'])) {
            // It is a callback / function?
            if (is_array($v) and !empty($v['_FUNC_'])) {
                $val = $v['_FUNC_'];
            } else {
                // Sanitize value
                $val = (is_int($v) or is_numeric($v)) ? $v : "'{$v}'";
            }
            // Print option
            echo $k . ': ' . $val . $comma;
            //
            // Print array option
            //
        } else {
            cx_print_custom_opts($v, $k);
        }
        $i++;
    }
    if ($property) {
        echo "},\n\t\t\t";
    }
}