Example #1
0
 $gom_utils->update_option('gp_table_prefix', 'gom_');
 $gom_utils->update_option('GP_GOOGLE_TRANSLATE', false);
 $gom_utils->update_option('GP_USE_SLUG_FOR_DOWNLOADS', true);
 $gom_utils->update_option('GP_REMOVE_PROJECTS_FROM_BREADCRUMS', false);
 $gom_utils->update_option('GP_REMOVE_PROJECTS_FROM_BREADCRUMS_LOGO_URL', '');
 $gom_utils->update_option('GP_WORDPRESS_SINGLE_SIGN_ON', true);
 $gom_utils->update_option('GP_NEW_WINDOW_FOR_EXTERNAL_LINKS', true);
 $gom_utils->update_option('GP_REMOVE_POWERED_BY', true);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS', true);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_PO', false);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_MO', false);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_ANDROID', false);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_RESX', false);
 $gom_utils->update_option('GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_STRINGS', false);
 // Write out the config file.
 gom_write_gp_config_file();
 // Get the schema for the database.
 $schema = gom_config_schema_array($gom_utils->get_option('gp_table_prefix'));
 // Create each of the tables.
 foreach ($schema as $table) {
     $wpdb->query($table . " DEFAULT CHARACTER SET 'utf8'");
 }
 // avoid duplicating permissions just in case.
 if ($wpdb->get_var("SELECT count(id) FROM gom_permissions") == 0) {
     // By default, assign all WordPress admins as GlotPress admins.
     $admins = get_users("role=administrator");
     foreach ($admins as $admin) {
         $sqlstring = $wpdb->prepare('INSERT INTO ' . $gom_utils->get_option('gp_table_prefix') . 'permissions (user_id, action) VALUES ( %d, %s);', $admin->ID, 'admin');
         $wpdb->query($sqlstring);
     }
 }
Example #2
0
function gom_admin_page()
{
    global $gpdb, $gom_utils;
    $gom_options = gom_user_options_array();
    if (array_key_exists('gom-options-save', $_POST)) {
        foreach ($gom_options as $key => $option) {
            if (array_key_exists($key, $_POST)) {
                $setting = esc_html($_POST[$key]);
                $gom_utils->update_option($key, $setting);
            } else {
                if ($option['type'] == 'bool') {
                    $gom_utils->update_option($key, false);
                }
            }
        }
        gom_write_gp_config_file();
    }
    ?>
<div class="wrap">
	<fieldset style="border:1px solid #cecece;padding:15px; margin-top:25px" >
		<legend><span style="font-size: 24px; font-weight: 700;">&nbsp;<?php 
    _e('Glot-O-Matic Options');
    ?>
&nbsp;</span></legend>
		<form method="post">

				<table>
<?php 
    foreach ($gom_options as $name => $option) {
        switch ($option['type']) {
            case 'title':
                echo "\t\t\t\t\t<tr><td colspan=\"2\"><h3>" . __($name) . "</h3></td></tr>\n";
                break;
            case 'desc':
                echo "\t\t\t\t\t<tr><td></td><td><span class=\"description\">" . __($option['desc']) . "</span></td></tr>\n";
                break;
            case 'bool':
                if ($gom_utils->get_option($name) == true) {
                    $checked = " CHECKED";
                } else {
                    $checked = "";
                }
                echo "\t\t\t\t\t<tr><td style=\"text-align: right;\">" . __($option['desc']) . ":</td><td><input name=\"{$name}\" value=\"1\" type=\"checkbox\" id=\"{$name}\"" . $checked . "></td></tr>\n";
                break;
            case 'image':
                echo "\t\t\t\t\t<tr><td style=\"text-align: right;\">" . __($option['desc']) . ":</td><td><input name=\"{$name}\" type=\"text\" size=\"40\" id=\"{$name}\" value=\"" . $gom_utils->get_option($name) . "\"></td></tr>\n";
                break;
            default:
                if ($option['height'] <= 1) {
                    echo "\t\t\t\t\t<tr><td style=\"text-align: right;\">" . __($option['desc']) . ":</td><td><input name=\"{$name}\" type=\"text\" size=\"{$option['size']}\" id=\"{$name}\" value=\"" . $gom_utils->get_option($name) . "\"></td></tr>\n";
                } else {
                    echo "\t\t\t\t\t<tr><td style=\"text-align: right;\">" . __($option['desc']) . ":</td><td><textarea name=\"{$name}\" type=\"text\" cols=\"{$option['size']}\" rows=\"{$option['height']}\" id=\"{$name}\">" . esc_html($gom_utils->get_option($name)) . "</textarea></td></tr>\n";
                }
        }
    }
    ?>
				</table>
			<div class="submit"><input type="submit" class="button button-primary" name="gom-options-save" value="<?php 
    _e('Update Options');
    ?>
" /></div>
		</form>
		
	</fieldset>
	
	<fieldset style="border:1px solid #cecece;padding:15px; margin-top:25px" >
		<legend><span style="font-size: 24px; font-weight: 700;">&nbsp;<?php 
    _e('About');
    ?>
&nbsp;</span></legend>
		<h2><?php 
    echo sprintf(__('Glot-O-Matic Version %s'), GOM_VERSION);
    ?>
</h2>
		<p><?php 
    _e('by');
    ?>
 <a href="https://profiles.wordpress.org/gregross" target=_blank>Greg Ross</a></p>
		<p>&nbsp;</p>
		<p><?php 
    printf(__('Licenced under the %sGPL Version 2%s'), '<a href="http://www.gnu.org/licenses/gpl-2.0.html" target=_blank>', '</a>');
    ?>
</p>
		<p><?php 
    printf(__('To find out more, please visit the %sGitHub repository page%s or %sglot-o-matic.com%s'), '<a href="https://github.com/toolstack/Glot-O-Matic" target=_blank>', '</a>', '<a href="http://glot-o-matic.com" target=_blank>', '</a>');
    ?>
</p>
	</fieldset>
</div>
	<?php 
}