public function setup_actions() { parent::setup_actions(); $this->main_site_id = gPluginWPHelper::getCurrentSiteBlogID(); // WORKING : add settings // allow only one session per user // add_action( 'wp_login', 'wp_destroy_other_sessions' ); }
public function network_settings_html($settings_uri, $sub) { echo '<form method="post" action="">'; $attachment_id = self::selectAttachment(gPluginFileHelper::mime('csv')); if ($attachment_id) { $file_path = gPluginWPHelper::get_attachmnet_path($attachment_id); $data = self::getCSV($file_path); // self::displayCSV( $data['data'], $data['titles'], 'google_contacts' ); // gnetwork_dump( $data['titles'] ); gnetwork_dump($data['data'][186]); } submit_button(); echo '</form>'; }
public static function post_type() { return gPluginWPHelper::getCurrentPostType(); }
public function is_admin() { return gPluginWPHelper::is_admin(); }
public function do_settings_field($atts) { $args = self::atts(array('title' => '', 'label_for' => '', 'type' => 'enabled', 'field' => FALSE, 'values' => array(), 'exclude' => '', 'none_title' => NULL, 'none_value' => NULL, 'filter' => FALSE, 'dir' => FALSE, 'default' => '', 'description' => isset($atts['desc']) ? $atts['desc'] : '', 'before' => '', 'after' => '', 'field_class' => '', 'class' => '', 'option_group' => $this->option_group, 'disabled' => FALSE, 'name_attr' => FALSE, 'id_attr' => FALSE, 'placeholder' => FALSE, 'constant' => FALSE, 'rekey' => FALSE), $atts); if ($args['rekey']) { self::__dep('gPluginUtils::sameKey()'); } if (!$args['field']) { return; } $html = ''; $value = isset($this->options[$args['field']]) ? $this->options[$args['field']] : $args['default']; $name = $args['name_attr'] ? $args['name_attr'] : $args['option_group'] . '[' . esc_attr($args['field']) . ']'; $id = $args['id_attr'] ? $args['id_attr'] : $args['option_group'] . '-' . esc_attr($args['field']); $exclude = $args['exclude'] && !is_array($args['exclude']) ? array_filter(explode(',', $args['exclude'])) : array(); if ($args['constant'] && defined($args['constant'])) { $value = constant($args['constant']); $args['disabled'] = TRUE; $args['after'] = '<code>' . $args['constant'] . '</code>'; } if ($args['before']) { echo $args['before'] . ' '; } switch ($args['type']) { case 'hidden': echo gPluginHTML::tag('input', array('type' => 'hidden', 'name' => $name, 'id' => $id, 'value' => $value)); $args['description'] = FALSE; break; case 'enabled': $html = gPluginHTML::tag('option', array('value' => '0', 'selected' => '0' == $value), isset($args['values'][0]) ? $args['values'][0] : esc_html__('Disabled')); $html .= gPluginHTML::tag('option', array('value' => '1', 'selected' => '1' == $value), isset($args['values'][1]) ? $args['values'][1] : esc_html__('Enabled')); echo gPluginHTML::tag('select', array('class' => $args['field_class'], 'name' => $name, 'id' => $id, 'dir' => $args['dir']), $html); break; case 'text': if (!$args['field_class']) { $args['field_class'] = 'regular-text'; } echo gPluginHTML::tag('input', array('type' => 'text', 'class' => $args['field_class'], 'name' => $name, 'id' => $id, 'value' => $value, 'dir' => $args['dir'], 'disabled' => $args['disabled'], 'placeholder' => $args['placeholder'])); break; case 'number': if (!$args['field_class']) { $args['field_class'] = 'small-text'; } if (!$args['dir']) { $args['dir'] = 'ltr'; } echo gPluginHTML::tag('input', array('type' => 'number', 'class' => $args['field_class'], 'name' => $name, 'id' => $id, 'value' => $value, 'step' => '1', 'min' => '0', 'dir' => $args['dir'], 'disabled' => $args['disabled'], 'placeholder' => $args['placeholder'])); break; case 'checkbox': if (count($args['values'])) { if (!is_null($args['none_title'])) { $html = gPluginHTML::tag('input', array('type' => 'checkbox', 'class' => $args['field_class'], 'name' => $name . (is_null($args['none_value']) ? '' : '-' . $args['none_value']), 'id' => $id . (is_null($args['none_value']) ? '' : '-' . $args['none_value']), 'value' => is_null($args['none_value']) ? '1' : $args['none_value'], 'checked' => in_array($args['none_value'], (array) $value), 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id . (is_null($args['none_value']) ? '' : '-' . $args['none_value'])), $html . ' ' . esc_html($args['none_title'])) . '</p>'; } foreach ($args['values'] as $value_name => $value_title) { if (in_array($value_name, $exclude)) { continue; } $html = gPluginHTML::tag('input', array('type' => 'checkbox', 'class' => $args['field_class'], 'name' => $name . '[' . $value_name . ']', 'id' => $id . '-' . $value_name, 'value' => '1', 'checked' => in_array($value_name, (array) $value), 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id . '-' . $value_name), $html . ' ' . esc_html($value_title)) . '</p>'; } } else { $html = gPluginHTML::tag('input', array('type' => 'checkbox', 'class' => $args['field_class'], 'name' => $name, 'id' => $id, 'value' => '1', 'checked' => $value, 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id), $html . ' ' . $args['description']) . '</p>'; $args['description'] = FALSE; } break; case 'radio': if (count($args['values'])) { if (!is_null($args['none_title'])) { $html = gPluginHTML::tag('input', array('type' => 'radio', 'class' => $args['field_class'], 'name' => $name, 'id' => $id . (is_null($args['none_value']) ? '' : '-' . $args['none_value']), 'value' => is_null($args['none_value']) ? FALSE : $args['none_value'], 'checked' => in_array($args['none_value'], (array) $value), 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id . (is_null($args['none_value']) ? '' : '-' . $args['none_value'])), $html . ' ' . esc_html($args['none_title'])) . '</p>'; } foreach ($args['values'] as $value_name => $value_title) { if (in_array($value_name, $exclude)) { continue; } $html = gPluginHTML::tag('input', array('type' => 'radio', 'class' => $args['field_class'], 'name' => $name, 'id' => $id . '-' . $value_name, 'value' => $value_name, 'checked' => in_array($value_name, (array) $value), 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id . '-' . $value_name), $html . ' ' . esc_html($value_title)) . '</p>'; } } break; case 'select': if (FALSE !== $args['values']) { // alow hiding if (!is_null($args['none_title'])) { $html .= gPluginHTML::tag('option', array('value' => is_null($args['none_value']) ? FALSE : $args['none_value'], 'selected' => $value == $args['none_value']), esc_html($args['none_title'])); } foreach ($args['values'] as $value_name => $value_title) { if (in_array($args['rekey'] ? $value_title : $value_name, $exclude)) { continue; } $html .= gPluginHTML::tag('option', array('value' => $args['rekey'] ? $value_title : $value_name, 'selected' => $value == $value_name), esc_html($value_title)); } echo gPluginHTML::tag('select', array('name' => $name, 'id' => $id, 'class' => $args['field_class'], 'disabled' => $args['disabled'], 'dir' => $args['dir']), $html); } break; case 'textarea': if (!$args['field_class']) { $args['field_class'] = 'large-text'; } echo gPluginHTML::tag('textarea', array('name' => $name, 'id' => $id, 'rows' => 5, 'cols' => 45, 'class' => $args['field_class'], 'disabled' => $args['disabled'], 'placeholder' => $args['placeholder']), $value); break; case 'button': echo get_submit_button($value, empty($args['field_class']) ? 'secondary' : $args['field_class'], $args['field'], FALSE, $args['values']); break; case 'file': echo gPluginHTML::tag('input', array('type' => 'file', 'name' => $id, 'id' => $id, 'class' => $args['field_class'], 'disabled' => $args['disabled'], 'dir' => $args['dir'])); break; case 'posttypes': foreach (gPluginWPHelper::getPostTypes() as $value_name => $value_title) { if (in_array($value_name, $exclude)) { continue; } $html = gPluginHTML::tag('input', array('type' => 'checkbox', 'class' => $args['field_class'], 'name' => $name . '[' . $value_name . ']', 'id' => $id . '-' . $value_name, 'value' => '1', 'checked' => in_array($value_name, (array) $value), 'disabled' => $args['disabled'], 'dir' => $args['dir'])); echo '<p>' . gPluginHTML::tag('label', array('for' => $id . '-' . $value_name), $html . ' ' . esc_html($value_title)) . '</p>'; } break; case 'custom': if (!is_array($args['values'])) { echo $args['values']; } else { echo $value; } break; case 'debug': gPluginUtils::dump($this->options); break; default: echo 'Error: setting type not defind'; } if ($args['after']) { echo ' ' . $args['after']; } if ($args['description'] && FALSE !== $args['values']) { echo gPluginHTML::tag('p', array('class' => 'description'), $args['description']); } }
public function footer_asset_config() { if (!$this->asset_config) { return; } $args = $this->asset_args; $args['api'] = defined('GNETWORK_AJAX_ENDPOINT') && GNETWORK_AJAX_ENDPOINT ? GNETWORK_AJAX_ENDPOINT : admin_url('admin-ajax.php'); ?> <script type="text/javascript"> /* <![CDATA[ */ var <?php echo $this->asset_object; ?> = <?php echo wp_json_encode($args); ?> ; <?php if (gPluginWPHelper::isDev()) { echo 'console.log(' . $this->asset_object . ');'; } ?> /* ]]> */ </script><?php }