abspath_file = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'cforms' . DIRECTORY_SEPARATOR . 'abspath.php'; $this->cforms_js_file = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'cforms' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'cforms.js'; add_action( 'admin_menu', array(&$this, 'addMenu') ); } } /** * Add page cforms on menu * * @return void * @author Amaury Balmer */ function addMenu() { add_options_page( __('Adv Edit Cforms', 'adv-cforms'), __('Adv Edit Cforms', 'adv-cforms'), 'manage_options', 'adv-cforms', array( &$this, 'pageOptions' ) ); } /** * Display many options of cforms * * @return void * @author Amaury Balmer */ function pageOptions() { if ( isset($_POST['submit_adv_cforms']) ) { if ( !current_user_can('manage_options') ) die(__( 'You cannot edit the Advanced Cforms options.', 'adv-cforms' )); check_admin_referer( 'adv-cforms-options' ); // DB Options if ( isset($_POST['cforms']) ) { $current_options = get_option( $this->option_name ); $current_options = $this->array_merge_recursive_distinct( $current_options, $_POST['cforms'] ); update_option( $this->option_name, $current_options ); } // File abs path if ( isset($_POST['abs-path-file']) && is_writable($this->abspath_file) ) { $_POST['abs-path-file'] = stripslashes($_POST['abs-path-file']); if ( file_get_contents( $this->abspath_file ) != $_POST['abs-path-file'] ) { file_put_contents( $this->abspath_file, $_POST['abs-path-file'] ); } } // JS File if ( isset($_POST['cforms-js-file']) && is_writable($this->cforms_js_file) ) { $new_file = array(); $_POST['cforms-js-file'] = stripslashes($_POST['cforms-js-file']); $lines = file( $this->cforms_js_file ); foreach ($lines as $line_num => $line) { if ( strpos( $line, 'var sajax_uri =' ) !== false ) { $new_file[] = $_POST['cforms-js-file']; } else { $new_file[] = $line; } } file_put_contents( $this->cforms_js_file, implode( '', $new_file ) ); } echo '
'.__('Options updated with succes !', 'adv-cforms').'